Make an internal function public, because it was used outside of the defining module.

This commit is contained in:
Dave Halter
2017-05-19 10:05:45 -04:00
parent c1010008af
commit 4bc5e27430
3 changed files with 5 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ import os
from parso.utils import splitlines, source_to_unicode from parso.utils import splitlines, source_to_unicode
from parso._compatibility import FileNotFoundError from parso._compatibility import FileNotFoundError
from parso.pgen2.pgen import generate_grammar 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.python.diff import DiffParser
from parso.tokenize import generate_tokens from parso.tokenize import generate_tokens
from parso.cache import parser_cache, load_module, save_module 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) p = Parser(grammar, error_recovery=error_recovery, start_symbol=start_symbol)
root_node = p.parse(tokens=tokens) root_node = p.parse(tokens=tokens)
if added_newline: if added_newline:
_remove_last_newline(root_node) remove_last_newline(root_node)
if cache or diff_cache: if cache or diff_cache:
save_module(grammar, path, root_node, lines, pickling=cache, save_module(grammar, path, root_node, lines, pickling=cache,

View File

@@ -11,7 +11,7 @@ from collections import namedtuple
import logging import logging
from parso.utils import splitlines 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.python.tree import EndMarker
from parso.tokenize import (generate_tokens, NEWLINE, TokenInfo, from parso.tokenize import (generate_tokens, NEWLINE, TokenInfo,
ENDMARKER, INDENT, DEDENT) ENDMARKER, INDENT, DEDENT)
@@ -160,7 +160,7 @@ class DiffParser(object):
self._nodes_stack.close() self._nodes_stack.close()
if self._added_newline: if self._added_newline:
_remove_last_newline(self._module) remove_last_newline(self._module)
last_pos = self._module.end_pos[0] last_pos = self._module.end_pos[0]
if last_pos != line_length: if last_pos != line_length:

View File

@@ -195,7 +195,7 @@ class Parser(BaseParser):
yield typ, value, start_pos, prefix yield typ, value, start_pos, prefix
def _remove_last_newline(node): def remove_last_newline(node):
endmarker = node.children[-1] endmarker = node.children[-1]
# The newline is either in the endmarker as a prefix or the previous # The newline is either in the endmarker as a prefix or the previous
# leaf as a newline token. # leaf as a newline token.