Commit aadd32d1 authored by Christophe Benz's avatar Christophe Benz

Add helper

parent fbb11db1
...@@ -5,7 +5,7 @@ from . import loaders ...@@ -5,7 +5,7 @@ from . import loaders
class VariablesDefinitions(object): class VariablesDefinitions(object):
"""Query `variables_definitions.json` file in a more convenient way.""" """Query `variables_definitions.json` file in a convenient way."""
def __init__(self, definition_by_variable_name=None): def __init__(self, definition_by_variable_name=None):
self.definition_by_variable_name = definition_by_variable_name or loaders.load_variables_definitions() self.definition_by_variable_name = definition_by_variable_name or loaders.load_variables_definitions()
...@@ -26,8 +26,11 @@ class VariablesDefinitions(object): ...@@ -26,8 +26,11 @@ class VariablesDefinitions(object):
return self.definition_by_variable_name.get(variable_name, default).get('type') return self.definition_by_variable_name.get(variable_name, default).get('type')
def is_calculee(self, variable_name, kind=None): def is_calculee(self, variable_name, kind=None):
return self.get_type(variable_name) == 'variable_calculee' and \ return self.is_type(variable_name, type='variable_calculee', kind=kind)
(True if kind is None else self.definition_by_variable_name[variable_name].get(kind))
def is_saisie(self, variable_name, kind=None):
return self.is_type(variable_name, type='variable_saisie', kind=kind)
def is_saisie(self, variable_name): def is_type(self, variable_name, type, kind=None):
return self.get_type(variable_name) == 'variable_saisie' return self.get_type(variable_name) == type and \
(True if kind is None else self.definition_by_variable_name[variable_name].get(kind))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment