Commit 16d9e979 authored by Christophe Benz's avatar Christophe Benz

Remove constants from VariablesDefinitions

parent 9b87eaa7
......@@ -31,7 +31,7 @@ from calculette_impots.variables_definitions import VariablesDefinitions
arguments = None
constants = loaders.load_constants()
dependencies_by_formula_name = loaders.load_formulas_dependencies()
variables_definitions = VariablesDefinitions(constants=constants)
variables_definitions = VariablesDefinitions()
def calculate(calculee_variable_names=[], saisie_variables={}):
......
......@@ -150,6 +150,7 @@ $verifs
# Transpile formulas
constants = loaders.load_constants()
source_by_formula_name = dict(list(mapcat(
load_regles_file,
iter_ast_json_file_names(filenames=['chap-*.json', 'res-ser*.json']),
......@@ -164,7 +165,7 @@ $verifs
expression='saisie_variables.get({!r}, 0)'.format(variable_name),
formula_name=variable_name,
)
if variables_definitions.is_constant(variable_name):
if variable_name in constants:
return python_source_visitors.make_formula_source(
expression='constants[{!r}]'.format(variable_name),
formula_name=variable_name,
......
......@@ -7,8 +7,7 @@ from . import loaders
class VariablesDefinitions(object):
"""Query `variables_definitions.json` file in a more convenient way."""
def __init__(self, constants=None, definition_by_variable_name=None):
self.constants = constants or loaders.load_constants()
def __init__(self, definition_by_variable_name=None):
self.definition_by_variable_name = definition_by_variable_name or loaders.load_variables_definitions()
def filter_calculees(self, kind=None):
......@@ -30,8 +29,5 @@ class VariablesDefinitions(object):
return self.get_type(variable_name) == 'variable_calculee' and \
(True if kind is None else self.definition_by_variable_name[variable_name].get(kind))
def is_constant(self, variable_name):
return variable_name in self.constants
def is_saisie(self, variable_name):
return self.get_type(variable_name) == 'variable_saisie'
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