def _init_env_variables(self): """ From the given config, build a list of variables from config.software.env_name.[alg].[] fields. env_variables = {alg: {segment_id: {var_name: var_type, }, }, } where Var contains name and type for the variables. """ self.env_variables = {} if hasattr(self.config.software, self.env_name): envs = getattr(self.config.software, self.env_name) for segment_id, env in envs.items(): # check each segment algs = list(vars(env).keys()) algs.remove('dettype') algs.remove('detid') for alg in algs: seg_alg = getattr(envs[segment_id], alg) env_vars = {} for var_name in vars(seg_alg): if var_name in ('version', 'software'): continue var_obj = getattr(seg_alg, var_name) if hasattr(var_obj, '_type') == False: continue var_type = DetectorImpl._return_types( var_obj._type, var_obj._rank) env_vars[var_name] = var_type self.env_variables[alg] = {segment_id: env_vars}
def _init_env_variables(self): """ From the given config, build a list of variables from config.software.env_name.[alg].[] fields. env_variables = {alg: {segment_id: {var_name: var_type, }, }, } where Var contains name and type for the variables. epics_mappers = {var_name: epics_name} # only valid for epics """ self.env_variables = {} self.epics_mapper = {} self.epics_inv_mapper = {} if hasattr(self.config.software, self.env_name): envs = getattr(self.config.software, self.env_name) for segment_id, env in envs.items(): # check each segment algs = list(vars(env).keys()) algs.remove('dettype') algs.remove('detid') for alg in algs: seg_alg = getattr(envs[segment_id], alg) env_vars = {} for var_name in vars(seg_alg): if var_name in ('version', 'software'): continue # Collect name mapping table for epics if self.env_name == 'epics': if hasattr(self.config, 'epicsinfo'): epicsinfo = getattr(self.config, 'epicsinfo') for eseg_id, epicsinfo_seg in epicsinfo.items( ): epics_names = getattr( epicsinfo_seg, 'epicsinfo') if var_name in epics_names.__dict__: epics_value = getattr( epics_names, var_name) self.epics_mapper[ var_name] = epics_value self.epics_inv_mapper[ epics_value] = var_name var_obj = getattr(seg_alg, var_name) if hasattr(var_obj, '_type') == False: continue var_type = DetectorImpl._return_types( var_obj._type, var_obj._rank) env_vars[var_name] = var_type self.env_variables[alg] = {segment_id: env_vars}