adding dot-notation
This commit is contained in:
parent
37aff587b4
commit
a0ea3ffb8f
@ -135,6 +135,10 @@ class AST27Converter(object):
|
|||||||
"for": self._ast_for,
|
"for": self._ast_for,
|
||||||
"kwapply": self._ast_kwapply,
|
"kwapply": self._ast_kwapply,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.starts_with = {
|
||||||
|
".": self._ast_dot_fnc
|
||||||
|
}
|
||||||
self.in_fn = False
|
self.in_fn = False
|
||||||
|
|
||||||
def _def(self, node):
|
def _def(self, node):
|
||||||
@ -150,6 +154,30 @@ class AST27Converter(object):
|
|||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def _ast_dot_fnc(self, node):
|
||||||
|
i = node.get_invocation()
|
||||||
|
fn = i['function'][1:]
|
||||||
|
args = i['args']
|
||||||
|
attr = args.pop(0)
|
||||||
|
val = self.render(attr)
|
||||||
|
|
||||||
|
a = []
|
||||||
|
for arg in args:
|
||||||
|
a.append(self.render(arg))
|
||||||
|
|
||||||
|
return ast.Call(
|
||||||
|
func=ast.Attribute(
|
||||||
|
value=val,
|
||||||
|
attr=fn,
|
||||||
|
ctx=ast.Load()
|
||||||
|
),
|
||||||
|
args=a,
|
||||||
|
keywords=[],
|
||||||
|
starargs=None,
|
||||||
|
kwargs=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _ast_kwapply(self, node):
|
def _ast_kwapply(self, node):
|
||||||
i = node.get_invocation()
|
i = node.get_invocation()
|
||||||
args = i['args']
|
args = i['args']
|
||||||
@ -174,8 +202,8 @@ class AST27Converter(object):
|
|||||||
body = body if isinstance(body, list) else [body]
|
body = body if isinstance(body, list) else [body]
|
||||||
orel = []
|
orel = []
|
||||||
|
|
||||||
body = _adjust_body(body, do_ret=self.in_fn)
|
body = _adjust_body(body, do_ret=False)
|
||||||
orel = _adjust_body(orel, do_ret=self.in_fn)
|
orel = _adjust_body(orel, do_ret=False)
|
||||||
|
|
||||||
return ast.While(
|
return ast.While(
|
||||||
test=test,
|
test=test,
|
||||||
@ -306,6 +334,10 @@ class AST27Converter(object):
|
|||||||
if inv['function'] in self.native_cases:
|
if inv['function'] in self.native_cases:
|
||||||
return self.native_cases[inv['function']](node)
|
return self.native_cases[inv['function']](node)
|
||||||
|
|
||||||
|
for flag in self.starts_with:
|
||||||
|
if inv['function'].startswith(flag):
|
||||||
|
return self.starts_with[flag](node)
|
||||||
|
|
||||||
c = []
|
c = []
|
||||||
for child in node.get_children():
|
for child in node.get_children():
|
||||||
c.append(self.render(child))
|
c.append(self.render(child))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user