Load JOY_HOME/definitions.txt
You still can't edit other text files from within the UI, but at least now you have a place to persist your own definitions over restarts. I thought about having a [definitions] section in the config INI file, but for some reason I prefer a separate definitions.txt file. I dunno. Might change it in future.
This commit is contained in:
@@ -380,6 +380,13 @@ class DefinitionWrapper(object):
|
||||
_log.info('Adding definition %s := %s', F.name, expression_to_string(F.body))
|
||||
dictionary[F.name] = F
|
||||
|
||||
@classmethod
|
||||
def load_definitions(class_, filename, dictionary):
|
||||
with open(filename) as f:
|
||||
lines = [line for line in f if '==' in line]
|
||||
for line in lines:
|
||||
class_.add_def(line, dictionary)
|
||||
|
||||
|
||||
def _text_to_defs(text):
|
||||
return (line.strip() for line in text.splitlines() if '==' in line)
|
||||
|
||||
Reference in New Issue
Block a user