def get_application_data(data, **kwargs): assert 'method' in data assert data.method in _METHODS, \ 'unknown application data method: {}'.format(data.method) cv = code_variable.CodeVar( data.variables, code_variable.PurePythonEval(_MADX_CONSTANTS), case_insensitive=True, ) if data.method == 'rpn_value': # accept array of values enclosed in curly braces if re.search(r'^\{.*\}$', data.value): data.result = '' return data v, err = cv.eval_var(data.value) if err: data.error = err else: data.result = v return data if data.method == 'recompute_rpn_cache_values': cv.recompute_cache(data.cache) return data if data.method == 'validate_rpn_delete': model_data = simulation_db.read_json( simulation_db.sim_data_file(data.simulationType, data.simulationId)) data.error = cv.validate_var_delete( data.name, model_data, _SCHEMA ) return data
def _code_var(variables): return code_variable.CodeVar( variables, code_variable.PurePythonEval(_OPAL_CONSTANTS), case_insensitive=True, )