mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-26 06:01:15 +08:00
More small changes.
This commit is contained in:
@@ -88,16 +88,17 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
|||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
code = source_to_unicode(f.read())
|
code = source_to_unicode(f.read())
|
||||||
|
|
||||||
|
lines = tokenize_lines = splitlines(code, keepends=True)
|
||||||
if diff_cache:
|
if diff_cache:
|
||||||
try:
|
try:
|
||||||
module_cache_item = parser_cache[path]
|
module_cache_item = parser_cache[path]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
lines = splitlines(code, keepends=True)
|
|
||||||
module_node = module_cache_item.node
|
module_node = module_cache_item.node
|
||||||
old_lines = module_cache_item.lines
|
old_lines = module_cache_item.lines
|
||||||
if old_lines == lines:
|
if old_lines == lines:
|
||||||
|
# TODO remove this line? I think it's not needed. (dave)
|
||||||
save_module(grammar, path, module_node, lines, pickling=False,
|
save_module(grammar, path, module_node, lines, pickling=False,
|
||||||
cache_path=cache_path)
|
cache_path=cache_path)
|
||||||
return module_node
|
return module_node
|
||||||
@@ -110,7 +111,6 @@ def parse(code=None, path=None, grammar=None, error_recovery=True,
|
|||||||
cache_path=cache_path)
|
cache_path=cache_path)
|
||||||
return new_node
|
return new_node
|
||||||
|
|
||||||
lines = tokenize_lines = splitlines(code, keepends=True)
|
|
||||||
added_newline = not code.endswith('\n')
|
added_newline = not code.endswith('\n')
|
||||||
if added_newline:
|
if added_newline:
|
||||||
code += '\n'
|
code += '\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user