Skip to content
Permalink
Browse files

Merge pull request #1432 from gvellut/master

Fix #9020
  • Loading branch information
NathanW2 committed Jun 9, 2014
2 parents a59b54e + 1357c14 commit 45e712f1002984a30bd4676ae82f8a3ffb8c3467
Showing with 4 additions and 3 deletions.
  1. +4 −3 python/utils.py
@@ -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:

0 comments on commit 45e712f

Please sign in to comment.