Move the utility function parse to the __init__ script.

This commit is contained in:
Dave Halter
2017-05-24 00:08:09 -04:00
parent 25941bbfb8
commit f2c257d7dd
11 changed files with 19 additions and 17 deletions

View File

@@ -20,4 +20,14 @@ PythonNode(simple_stmt, [PythonNode(arith_expr, [...]), <Newline: ''>])
from parso.parser import ParserSyntaxError
from parso.grammar import create_grammar, load_python_grammar
def parse(code=None, **kwargs):
"""
A utility function to parse Python with the current Python version. Params
are documented in ``Grammar.parse``.
"""
grammar = load_python_grammar()
return grammar.parse(code, **kwargs)
__version__ = '0.0.2'

View File

@@ -1,8 +0,0 @@
"""
Parsers for Python
"""
def parse(code, **kwargs):
from parso import load_python_grammar
grammar = load_python_grammar()
return grammar.parse(code, **kwargs)

View File

@@ -12,7 +12,7 @@ the input given to the parser. This is important if you are using refactoring.
The easiest way to play with this module is to use :class:`parsing.Parser`.
:attr:`parsing.Parser.module` holds an instance of :class:`Module`:
>>> from parso.python import parse
>>> from parso import parse
>>> parser = parse('import os')
>>> module = parser.get_root_node()
>>> module