Si vous constatez la perte de tickets, de commentaires ou de projets, veuillez consulter la page https://status.framasoft.org/incident/626.

Commit 6502e0fe authored by Christophe Benz's avatar Christophe Benz

Add basic generated modules loader

parent 36e300f1
......@@ -28,6 +28,10 @@ def has_tag(tag, variable_definition):
return tag in variable_definition.get('attributes', {}).get('tags', [])
def load_environment():
formulas.load_formulas()
class Simulation(object):
def __init__(self, value_by_variable_name=None):
self.value_by_variable_name = {} if value_by_variable_name is None else value_by_variable_name
......
from .generated.chap_1 import *
from .generated.chap_2 import *
# -*- coding: utf-8 -*-
import glob
import importlib
import os
import pkg_resources
def load_formulas():
distribution_dir_path = pkg_resources.get_distribution('calculateur_impots').location
for file_path in sorted(glob.iglob(os.path.join(distribution_dir_path, 'calculateur_impots', 'generated', '*.py'))):
file_name = os.path.splitext(os.path.basename(file_path))[0]
importlib.import_module('.generated.' + file_name, 'calculateur_impots')
......@@ -62,6 +62,8 @@ def main():
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.verbose or args.debug else logging.WARNING, stream=sys.stdout)
core.load_environment()
variables_saisies = {variable_name: value for variable_name, value in iter_variables_saisies(args.variables)}
simulation = core.Simulation(value_by_variable_name=variables_saisies)
variables_calculees = [variable_name for variable_name in iter_variables_calculees(args.variables)]
......
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