Skip to content

Commit

Permalink
Expose "context" to expression functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 5, 2017
1 parent 028c64e commit 5f7a291
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ def func(self, values, context, parent):
feature = None
if context:
feature = context.feature()

try:
if self.expandargs:
values.append(feature)
values.append(parent)
if inspect.getargspec(self.function).args[-1] == 'context':
values.append(context)
return self.function(*values)
else:
if inspect.getargspec(self.function).args[-1] == 'context':
self.function(values, feature, parent, context)
return self.function(values, feature, parent)
except Exception as ex:
parent.setEvalErrorString(str(ex))
Expand All @@ -113,6 +118,8 @@ def referencedColumns(self, node):
args = inspect.getargspec(function).args
number = len(args)
arg_count = number - 2
if args[-1] == 'context':
arg_count -= 1
expandargs = True

register = kwargs.get('register', True)
Expand Down

0 comments on commit 5f7a291

Please sign in to comment.