def resolve_indicator_def(self): """ Resolve the Indicator definition based on name. Translations to class names for matching: - Some Indicator classes end with "Indicator" - # and % might be in object names, but can't appear in class names. Translate to 'Num' and 'Pct' """ from core.indicators import indicator_list possible_names = [] translated_name = self.name translated_name = translated_name.replace('#', 'Num') translated_name = translated_name.replace('%', 'Pct') translated_name = translated_name.replace(' ', '') translated_name = translated_name.upper() possible_names.append(translated_name) possible_names.append(translated_name + 'INDICATOR') resolved_def = None for indicator_def in indicator_list(include_new=True): if indicator_def.__name__.upper() in possible_names: if resolved_def: print "Found multiple definitions for %s:" % self.name print "\t%s" % resolved_def print "\t%s\n\n" % indicator_def raise Indicator.MultipleDefinitionsFoundException( "Found multiple definitions for this Indicator") resolved_def = indicator_def return resolved_def
def resolve_indicator_def(self): """ Resolve the Indicator definition based on name. Translations to class names for matching: - Some Indicator classes end with "Indicator" - # and % might be in object names, but can't appear in class names. Translate to 'Num' and 'Pct' """ from core.indicators import indicator_list possible_names = [] translated_name = self.name translated_name = translated_name.replace("#", "Num") translated_name = translated_name.replace("%", "Pct") translated_name = translated_name.replace(" ", "") translated_name = translated_name.upper() possible_names.append(translated_name) possible_names.append(translated_name + "INDICATOR") resolved_def = None for indicator_def in indicator_list(include_new=True): if indicator_def.__name__.upper() in possible_names: if resolved_def: print "Found multiple definitions for %s:" % self.name print "\t%s" % resolved_def print "\t%s\n\n" % indicator_def raise Indicator.MultipleDefinitionsFoundException("Found multiple definitions for this Indicator") resolved_def = indicator_def return resolved_def
def indicator_debug_batch(indicators_to_run, batch_folder): from core.indicators import indicator_list # whip up a logger that outputs to the batch directory for the indicators logger = _get_batch_logger(batch_folder) [idef(debug=True,logger=logger).csv_output(idef.__name__,path=batch_folder) for idef in indicator_list() if idef.__name__ in indicators_to_run] logger.debug('Batch Finished') # create a tar.gz of the batch directory os.system('tar -cvzf %s %s' % ( os.path.join(batch_folder, 'batch.tar.gz'), batch_folder, ) )
def indicator_debug_batch(indicators_to_run, batch_folder): from core.indicators import indicator_list # whip up a logger that outputs to the batch directory for the indicators logger = _get_batch_logger(batch_folder) [ idef(debug=True, logger=logger).csv_output(idef.__name__, path=batch_folder) for idef in indicator_list() if idef.__name__ in indicators_to_run ] logger.debug('Batch Finished') # create a tar.gz of the batch directory os.system('tar -cvzf %s %s' % ( os.path.join(batch_folder, 'batch.tar.gz'), batch_folder, ))