def parse_trigger(alarm, line): if line.params.get("VALUE", [""])[0] == "DATE-TIME": alarm.trigger = iso_to_arrow(line) elif line.params.get("VALUE", ["DURATION"])[0] == "DURATION": alarm.trigger = parse_duration(line.value) else: warnings.warn( "ics.py encountered a TRIGGER of unknown type '%s'. It has been ignored." % line.params["VALUE"][0])
def run_on_dataset(self, dataset): for test in dataset: expected = dataset[test] self.assertEqual(parse_duration(test), timedelta(*expected))
def parse_duration(todo: "Todo", line: ContentLine): if line: todo._timespan = todo._timespan.replace( duration=parse_duration(line.value))
def parse_duration(todo: "Todo", line: ContentLine): if line: # TODO: DRY [1] if todo._due_time: # pragma: no cover raise ValueError("An todo can't have both DUE and DURATION") todo._duration = parse_duration(line.value)
def parse_duration(alarm, line): if line: alarm._duration = parse_duration(line.value)
def parse_duration(event, line): if line: # TODO: DRY [1] if event._end_time: # pragma: no cover raise ValueError("An event can't have both DTEND and DURATION") event._duration = parse_duration(line.value)
def test_negative(): s = "-PT30M" assert parse_duration(s) == timedelta(minutes=-30)
def test_simple(): s = "PT30M" assert parse_duration(s) == timedelta(minutes=30)
def test_no_sign(): s = "P0DT9H0M0S" assert parse_duration(s) == timedelta(hours=9)
def parse_duration(alarm: "BaseAlarm", line: ContentLine): if line: alarm.duration = parse_duration(line.value)
def parse2_duration(event: "Event", line: ContentLine): if line: event._timespan = event._timespan.replace( duration=parse_duration(line.value))