コード例 #1
0
ファイル: cron.py プロジェクト: mshafrir/Junkscast
def persist_segments(segment_props, out=None):
    for props in [props for props in segment_props if props]:
        printer(out, '%s:%02d (%s) - %s -> ' % \
            (props.get('date'), props.get('num'), \
                props.get('description'), props.get('is_classic')))
        if not Segment.lookup(date=props['date'], num=props['num']):
            segment = Segment.create(date=props['date'], num=props['num'], \
                            url=props['url'], description=props['description'], \
                            duration=props.get('duration', 0), \
                            is_classic=props.get('is_classic', False))
            logging.debug("created segment %s" % segment)
            printer(out, "just created.\n")
        else:
            printer(out, "already created.\n")