mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Make an internal function public, because it was used outside of the defining module.
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
||||
from parso.utils import splitlines, source_to_unicode
|
||||
from parso._compatibility import FileNotFoundError
|
||||
from parso.pgen2.pgen import generate_grammar
|
||||
from parso.python.parser import Parser, _remove_last_newline
|
||||
from parso.python.parser import Parser, remove_last_newline
|
||||
from parso.python.diff import DiffParser
|
||||
from parso.tokenize import generate_tokens
|
||||
from parso.cache import parser_cache, load_module, save_module
|
||||
@@ -136,7 +136,7 @@ def parse(code=None, **kwargs):
|
||||
p = Parser(grammar, error_recovery=error_recovery, start_symbol=start_symbol)
|
||||
root_node = p.parse(tokens=tokens)
|
||||
if added_newline:
|
||||
_remove_last_newline(root_node)
|
||||
remove_last_newline(root_node)
|
||||
|
||||
if cache or diff_cache:
|
||||
save_module(grammar, path, root_node, lines, pickling=cache,
|
||||
|
||||
@@ -11,7 +11,7 @@ from collections import namedtuple
|
||||
import logging
|
||||
|
||||
from parso.utils import splitlines
|
||||
from parso.python.parser import Parser, _remove_last_newline
|
||||
from parso.python.parser import Parser, remove_last_newline
|
||||
from parso.python.tree import EndMarker
|
||||
from parso.tokenize import (generate_tokens, NEWLINE, TokenInfo,
|
||||
ENDMARKER, INDENT, DEDENT)
|
||||
@@ -160,7 +160,7 @@ class DiffParser(object):
|
||||
self._nodes_stack.close()
|
||||
|
||||
if self._added_newline:
|
||||
_remove_last_newline(self._module)
|
||||
remove_last_newline(self._module)
|
||||
|
||||
last_pos = self._module.end_pos[0]
|
||||
if last_pos != line_length:
|
||||
|
||||
@@ -195,7 +195,7 @@ class Parser(BaseParser):
|
||||
yield typ, value, start_pos, prefix
|
||||
|
||||
|
||||
def _remove_last_newline(node):
|
||||
def remove_last_newline(node):
|
||||
endmarker = node.children[-1]
|
||||
# The newline is either in the endmarker as a prefix or the previous
|
||||
# leaf as a newline token.
|
||||
|
||||
Reference in New Issue
Block a user