aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-09-11 10:38:53 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-09-11 10:38:53 -0400
commite1086cd37e7075102fe9b895372ecacb98732457 (patch)
tree1e93504cb3552f6cbc707f6decd11f0c456bfe23
parentc5d7b54edc0cf35191e18663e5d35707d1f7592e (diff)
downloadexternal_python_mako-e1086cd37e7075102fe9b895372ecacb98732457.tar.gz
external_python_mako-e1086cd37e7075102fe9b895372ecacb98732457.tar.bz2
external_python_mako-e1086cd37e7075102fe9b895372ecacb98732457.zip
move the function out to compat so we don't import _ast_util if _ast isn't present
-rw-r--r--mako/_ast_util.py11
-rw-r--r--mako/ast.py2
-rw-r--r--mako/compat.py10
-rw-r--r--mako/pyparser.py4
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"""