def __init__(self, params, source_id=None, config=None, segment_id=ALL): super(PlanObject, self).__init__() self._data_source = None self._template_file = None self._source_type = None plan_allowed_parameters = getattr(config, 'PLAN_ALLOWED_PARAMETERS', {}) if not set(params.keys()).issubset(set( plan_allowed_parameters.keys())): raise HydroException( "Some parameters are not registered as valid in PLAN_ALLOWED_PARAMETERS" ) for key in params: tp = plan_allowed_parameters[key]['type'] try: val = params[key] is_optional = plan_allowed_parameters[key].get( 'optional', False) if is_optional and val is None: obj = val elif not isinstance(val, HydroType): obj = tp(val, **plan_allowed_parameters[key]) else: obj = val self.__dict__[key] = obj params[key] = obj except: raise HydroException( 'Parsing parameter {0} failed with value {1}'.format( key, val.value)) self.logger = get_logger() self._sampling = False self.gather_statistics(source_id, segment_id)
def __init__(self, params, source_id=None, config=None, segment_id=ALL): super(PlanObject, self).__init__() self._data_source = None self._template_file = None self._source_type = None plan_allowed_parameters = getattr(config, 'PLAN_ALLOWED_PARAMETERS', {}) if not set(params.keys()).issubset(set(plan_allowed_parameters.keys())): raise HydroException("Some parameters are not registered as valid in PLAN_ALLOWED_PARAMETERS") for key in params: tp = plan_allowed_parameters[key]['type'] try: val = params[key] is_optional = plan_allowed_parameters[key].get('optional', False) if is_optional and val is None: obj = val elif not isinstance(val, HydroType): obj = tp(val, **plan_allowed_parameters[key]) else: obj = val self.__dict__[key] = obj params[key] = obj except: raise HydroException('Parsing parameter {0} failed with value {1}'.format(key, val.value)) self.logger = get_logger() self._sampling = False self.gather_statistics(source_id, segment_id)
def __init__(self): self.logger = get_logger() self.stats = stats_engine
def setUp(self): self.logger = get_logger()