Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gvellut committed Jun 8, 2014
1 parent 0b60118 commit 1357c14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/utils.py
Expand Up @@ -418,21 +418,22 @@ def add(values, *args):
"""
helptemplate = Template("""<h3>$name function</h3><br>$doc""")
class QgsExpressionFunction(QgsExpression.Function):
def __init__(self, name, args, group, helptext=''):
QgsExpression.Function.__init__(self, name, args, group, helptext)
def __init__(self, name, args, group, helptext='', usesgeometry=False):
QgsExpression.Function.__init__(self, name, args, group, helptext, usesgeometry)

def func(self, values, feature, parent):
pass

def wrapper(func):
name = kwargs.get('name', func.__name__)
usesgeometry = kwargs.get('usesgeometry', False)
help = func.__doc__ or ''
help = help.strip()
if args == 0 and not name[0] == '$':
name = '${0}'.format(name)
func.__name__ = name
help = helptemplate.safe_substitute(name=name, doc=help)
f = QgsExpressionFunction(name, args, group, help)
f = QgsExpressionFunction(name, args, group, help, usesgeometry)
f.func = func
register = kwargs.get('register', True)
if register:
Expand Down

0 comments on commit 1357c14

Please sign in to comment.