Skip to content

Commit

Permalink
Fix #13059 - Fix expression template load error
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jul 4, 2015
1 parent 4bff1e0 commit fbad680
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions python/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,26 @@ def load_user_expressions(path):
if not os.path.exists(initfile):
open(initfile, "w").close()

template = """\"\"\"
Define new functions using @qgsfunction. feature and parent must always be the
last args. Use args=-1 to pass a list of values as arguments
\"\"\"
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def func(value1, feature, parent):
return value1
"""


try:
import expressions

expressions.load = load_user_expressions
expressions.load(expressionspath)
expressions.template = """\"\"\"
Define new functions using @qgsfunction. feature and parent must always be the
last args. Use args=-1 to pass a list of values as arguments
\"\"\"
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def func(value1, feature, parent):
return value1
"""
expressions.template = template
except ImportError:
# We get a import error and crash for some reason even if we make the expressions package
# TODO Fix the crash on first load with no expressions folder
Expand Down

0 comments on commit fbad680

Please sign in to comment.