Commit b13ec5ac authored by Christophe Benz's avatar Christophe Benz

Misc updates

parent d1403d21
...@@ -69911,9 +69911,5 @@ def get_formulas(cache, saisie_variables): ...@@ -69911,9 +69911,5 @@ def get_formulas(cache, saisie_variables):
return ((formulas['VARIPTEFP']() and positif(formulas['ART1731BIS']()) and formulas['VARIPTEFP']() * positif(formulas['ART1731BIS']())) + (saisie_variables.get('IPTEFP', 0) and (1 - formulas['ART1731BIS']()) and saisie_variables.get('IPTEFP', 0) * (1 - formulas['ART1731BIS']()))) return ((formulas['VARIPTEFP']() and positif(formulas['ART1731BIS']()) and formulas['VARIPTEFP']() * positif(formulas['ART1731BIS']())) + (saisie_variables.get('IPTEFP', 0) and (1 - formulas['ART1731BIS']()) and saisie_variables.get('IPTEFP', 0) * (1 - formulas['ART1731BIS']())))
formulas['ZONIPTEFP'] = ZONIPTEFP formulas['ZONIPTEFP'] = ZONIPTEFP
return { return formulas
key: val
for key, val in locals().items()
if inspect.isfunction(val)
}
...@@ -74,12 +74,10 @@ def main(): ...@@ -74,12 +74,10 @@ def main():
log.warning(not_restituee_message) log.warning(not_restituee_message)
# parser.error(not_restituee_message) # parser.error(not_restituee_message)
saisie_variables = { saisie_variables = dict(iter_saisie_variables(args.saisie_variables))
'V_ANREV': 2014, if 'V_ANREV' not in saisie_variables:
} log.warning('V_ANREV should be given as a "saisie" variable. Hint: --saisie V_ANREV=2014')
if args.saisie_variables is not None: # log.debug('saisie_variables: {}'.format(saisie_variables))
saisie_variables.update(iter_saisie_variables(args.saisie_variables))
log.debug('saisie_variables: {}'.format(saisie_variables))
result_by_formula_name_cache = {} result_by_formula_name_cache = {}
formulas_functions = formulas.get_formulas( formulas_functions = formulas.get_formulas(
...@@ -95,28 +93,22 @@ def main(): ...@@ -95,28 +93,22 @@ def main():
if errors is not None: if errors is not None:
errors_definitions = load_errors_definitions() errors_definitions = load_errors_definitions()
definition_by_error_name = pipe(errors_definitions, map(lambda d: (d['name'], d)), dict) definition_by_error_name = pipe(errors_definitions, map(lambda d: (d['name'], d)), dict)
print('errors: {}'.format( log.error('verif errors: {}'.format(json.dumps(
json.dumps( [
[ (
( error,
error, definition_by_error_name.get(error, {}).get('description'),
definition_by_error_name.get(error, {}).get('description', 'No error description found'), )
) for error in unique(errors) # Keep order
for error in unique(errors) # Keep order ],
], indent=4,
indent=4, )))
),
))
for calculee_variable_name in args.calculee_variables: for calculee_variable_name in args.calculee_variables:
sanitized_calculee_variable = core.sanitized_variable_name(calculee_variable_name)
# requested_formula_result = formulas_functions[sanitized_calculee_variable]()
# print('{} = {} ({})'.format(calculee_variable_name, requested_formula_result,
# core.get_variable_description(calculee_variable_name)))
try: try:
requested_formula_result = formulas_functions[sanitized_calculee_variable]() requested_formula_result = formulas_functions[calculee_variable_name]()
except: except:
log.exception('Error while calculating {}'.format(sanitized_calculee_variable)) log.exception('Error while calculating {}'.format(calculee_variable_name))
else: else:
print('{} = {} ({})'.format(calculee_variable_name, requested_formula_result, print('{} = {} ({})'.format(calculee_variable_name, requested_formula_result,
core.get_variable_description(calculee_variable_name))) core.get_variable_description(calculee_variable_name)))
......
...@@ -219,11 +219,7 @@ def get_formulas(cache, saisie_variables): ...@@ -219,11 +219,7 @@ def get_formulas(cache, saisie_variables):
formulas = {} formulas = {}
$formulas $formulas
return { return formulas
key: val
for key, val in locals().items()
if inspect.isfunction(val)
}
""").substitute( """).substitute(
formulas=textwrap.indent( formulas=textwrap.indent(
'\n'.join(map(get_formula_source, formula_names)), '\n'.join(map(get_formula_source, formula_names)),
......
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