def __init__(self, interval, start_date=None): if not isinstance(interval, timedelta): raise TypeError('interval must be a timedelta') if start_date: start_date = convert_to_datetime(start_date) self.set_interval(interval) if start_date is None: self.start_date = datetime.now() + self.interval else: self.start_date = convert_to_datetime(start_date)
def __init__(self, **values): self.start_date = values.pop('start_date', None) if self.start_date: self.start_date = convert_to_datetime(self.start_date) # Yank out all None valued fields for key, value in list(iteritems(values)): if value is None: del values[key] self.fields = [] assign_defaults = False for field_name in self.FIELD_NAMES: if field_name in values: exprs = values.pop(field_name) is_default = False assign_defaults = not values elif assign_defaults: exprs = DEFAULT_VALUES[field_name] is_default = True else: exprs = '*' is_default = True field_class = self.FIELDS_MAP[field_name] field = field_class(field_name, exprs, is_default) self.fields.append(field)
def __init__(self, run_date): self.run_date = convert_to_datetime(run_date)