<s> from datetime import timedelta , date <EOL> from inferno . lib . rule import InfernoRule <EOL> class JobOptions ( object ) : <EOL> def __init__ ( self , rule , settings ) : <EOL> self . rule = rule <EOL> self . settings = settings <EOL> @ property <EOL> def result_tag ( self ) : <EOL> if self . settings . get ( '<STR_LIT>' ) : <EOL> return self . settings . get ( '<STR_LIT>' ) <EOL> else : <EOL> return self . rule . result_tag <EOL> @ property <EOL> def tags ( self ) : <EOL> def _filter_rules ( tags ) : <EOL> return [ tag for tag in tags if not isinstance ( tag , InfernoRule ) ] <EOL> if self . settings . get ( '<STR_LIT>' ) is not None : <EOL> tags = _filter_rules ( self . settings . get ( '<STR_LIT>' ) ) <EOL> else : <EOL> tags = _filter_rules ( self . rule . source_tags ) <EOL> count = None <EOL> if self . settings . get ( '<STR_LIT>' ) is not None : <EOL> start = self . settings . get ( '<STR_LIT>' ) <EOL> count = <NUM_LIT:1> <EOL> elif self . rule . day_start is not None : <EOL> start = self . rule . day_start <EOL> else : <EOL> start = date . today ( ) <EOL> if self . settings . get ( '<STR_LIT>' ) is not None : <EOL> start += timedelta ( days = - self . settings . get ( '<STR_LIT>' ) ) <EOL> count = <NUM_LIT:1> <EOL> else : <EOL> start += timedelta ( days = - self . rule . day_offset ) <EOL> if self . settings . get ( '<STR_LIT>' ) is not None : <EOL> count = self . settings . get ( '<STR_LIT>' ) <EOL> elif count is None : <EOL> count = self . rule . day_range <EOL> if count and tags : <EOL> tags = [ self . _name ( tag , day , start ) for tag in tags for day in range ( count ) ] <EOL> return tags or [ ] <EOL> @ property <EOL> def urls ( self ) : <EOL> import operator <EOL> urls_or_func = self . settings . get ( '<STR_LIT>' ) or getattr ( self . rule , '<STR_LIT>' , None ) <EOL> rval = urls_or_func <EOL> if operator . isCallable ( urls_or_func ) : <EOL> rval = urls_or_func ( self ) <EOL> return rval or [ ] <EOL> def _name ( self , tag , delta , start ) : <EOL> return '<STR_LIT>' % ( tag , start + timedelta ( days = - delta ) ) </s>
