diff options
| -rw-r--r-- | mako/_ast_util.py | 11 | ||||
| -rw-r--r-- | mako/ast.py | 2 | ||||
| -rw-r--r-- | mako/compat.py | 10 | ||||
| -rw-r--r-- | mako/pyparser.py | 4 |
4 files changed, 14 insertions, 13 deletions
diff --git a/mako/_ast_util.py b/mako/_ast_util.py index 2c6cbc7..3b0bd21 100644 --- a/mako/_ast_util.py +++ b/mako/_ast_util.py @@ -31,7 +31,7 @@ :license: Python License. """ from _ast import * - +from mako.compat import arg_stringname BOOLOP_SYMBOLS = { And: 'and', @@ -78,15 +78,6 @@ ALL_SYMBOLS.update(BINOP_SYMBOLS) ALL_SYMBOLS.update(CMPOP_SYMBOLS) ALL_SYMBOLS.update(UNARYOP_SYMBOLS) -def arg_stringname(func_arg): - """Gets the string name of a kwarg or vararg - In Python3.4 a function's args are - of _ast.arg type not _ast.name - """ - if hasattr(func_arg, 'arg'): - return func_arg.arg - else: - return str(func_arg) def parse(expr, filename='<unknown>', mode='exec'): """Parse an expression into an AST node.""" diff --git a/mako/ast.py b/mako/ast.py index cd1d14e..f9ae3e1 100644 --- a/mako/ast.py +++ b/mako/ast.py @@ -8,7 +8,7 @@ code, as well as generating Python from AST nodes""" from mako import exceptions, pyparser, compat -from mako._ast_util import arg_stringname +from mako.compat import arg_stringname import re class PythonCode(object): diff --git a/mako/compat.py b/mako/compat.py index 5e9c201..31da8bd 100644 --- a/mako/compat.py +++ b/mako/compat.py @@ -155,3 +155,13 @@ def with_metaclass(meta, base=object): return meta("%sBase" % meta.__name__, (base,), {}) ################################################ + +def arg_stringname(func_arg): + """Gets the string name of a kwarg or vararg + In Python3.4 a function's args are + of _ast.arg type not _ast.name + """ + if hasattr(func_arg, 'arg'): + return func_arg.arg + else: + return str(func_arg) diff --git a/mako/pyparser.py b/mako/pyparser.py index be292a8..75301cc 100644 --- a/mako/pyparser.py +++ b/mako/pyparser.py @@ -11,8 +11,7 @@ module is used. """ from mako import exceptions, util, compat -from mako._ast_util import arg_stringname -from mako.compat import StringIO +from mako.compat import StringIO, arg_stringname import operator if compat.py3k: @@ -41,6 +40,7 @@ except ImportError: from compiler import visitor + def parse(code, mode='exec', **exception_kwargs): """Parse an expression into AST""" |
