diff options
author | James Stewart <jstewart101@gmail.com> | 2014-03-20 07:39:08 +1100 |
---|---|---|
committer | James Stewart <jstewart101@gmail.com> | 2014-03-20 07:39:08 +1100 |
commit | 94799455372e105addb17f6aa65757be89ccd5e6 (patch) | |
tree | ba7e5913418c43d84bfaf646b23929a76971ea3f | |
parent | 6f7d0c025ec745b7b7ccb1d1784df3a5cff739de (diff) | |
download | cherrypy-94799455372e105addb17f6aa65757be89ccd5e6.tar.gz |
now handles functions with kwargs
-rw-r--r-- | cherrypy/lib/reprconf.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/cherrypy/lib/reprconf.py b/cherrypy/lib/reprconf.py index 67ed9f3c..6e70b5ec 100644 --- a/cherrypy/lib/reprconf.py +++ b/cherrypy/lib/reprconf.py @@ -264,13 +264,31 @@ class _Builder2: return expr[subs] def build_CallFunc(self, o): - children = map(self.build, o.getChildren()) - callee = children.pop(0) - kwargs = children.pop() or {} - starargs = children.pop() or () - args = tuple(children) + tuple(starargs) + children = o.getChildren() + # Build callee from first child + callee = self.build(children[0]) + # Build args and kwargs from remaining children + args = [] + kwargs = {} + for child in children[1:]: + class_name = child.__class__.__name__ + # None is ignored + if class_name == 'NoneType': + continue + # Keywords become kwargs + if class_name == 'Keyword': + kwargs.update(self.build(child)) + # Everything else becomes args + else : + args.append(self.build(child)) return callee(*args, **kwargs) + def build_Keyword(self, o): + key, value_obj = o.getChildren() + value = self.build(value_obj) + kw_dict = {key: value} + return kw_dict + def build_List(self, o): return map(self.build, o.getChildren()) |