示例#1
0
def main():
    cron_spec = parse_args(argv)

    timetable = CronTimeTable(minute=parse_field(Interval.MINUTE,
                                                 cron_spec.minute),
                              hour=parse_field(Interval.HOUR, cron_spec.hour),
                              day_of_month=parse_field(Interval.DAY_OF_MONTH,
                                                       cron_spec.day_of_month),
                              month=parse_field(Interval.MONTH,
                                                cron_spec.month),
                              day_of_week=parse_field(Interval.DAY_OF_WEEK,
                                                      cron_spec.day_of_week),
                              command=cron_spec.command)

    timetable_string = format_timetable(timetable)

    print(timetable_string)
示例#2
0
def test_parse_field_invalid_range():
    with raises(ValidationException, match='Invalid range'):
        parse_field(Interval.MINUTE, "5-1")
示例#3
0
def test_parse_field_invalid_value():
    with raises(ValidationException, match='Invalid value'):
        parse_field(Interval.MINUTE, "100")
示例#4
0
def test_parse_field_unexpected():
    with raises(ParsingException, match='Could not parse token'):
        parse_field(Interval.MINUTE, "*/-")
示例#5
0
def test_parse_field_short():
    with raises(ParsingException, match='end of input'):
        parse_field(Interval.MINUTE, "*/")
示例#6
0
def test_parse_field(interval, value, expected_parsed_values):
    parsed_values = parse_field(interval, value)
    assert parsed_values == expected_parsed_values