timetable.timetable
¶
Functions for timetable modification, for example merging, tagging and cutting at specific dates.
Returns an annotation function which parses the items summary for a tag. A tag is identified through the regular expression tag_pat. If no tag is found, emptytag is applied.
Note
The summary is assumed to be encoded as UTF-8.
-
timetable.timetable.
annotate_timetable
(timetable, *annotate_funcs)[source]¶ Annotates all entries of timetable with the result of all annotate_funcs. The annotation functions must accept the arguments start, end, entry.
-
timetable.timetable.
clip_timetable
(timetable, clip_start=None, clip_end=None, pending=None)[source]¶ Generates a timetable by clipping entries from the given timetable. Entries ending before clip_start are discarded as well as entries starting after clip_end. Start and end times of entries lying on the boundaries modified to match clip_start resp. clip_end. Entries on the clip_end are added to the list pending, if it is supplied.
-
timetable.timetable.
collect_keys
(key='tags', collection='entries')[source]¶ Returns an annotation function which collects key from a collection. The resulting set of keys is added to the entries dictionary under the key key.
This function is useful to extract tags from a merged timetable as returned by
merge_intersections()
for example.
-
timetable.timetable.
compute_duration
(key='tags')[source]¶ Returns an annotation function which computes the duration of an entry. The duration is allocated equally for each key of the entry (e.g. divided by the amount of keys).
-
timetable.timetable.
cut_timetable
(timetable, cuts=(None, None))[source]¶ Generates a timetable by cutting entries of timetable at the given cuts datetimes.
-
timetable.timetable.
generate_timetable
(calendar, itemtype=b'vevent')[source]¶ Generates a timetable from all items of type itemtype in the given calendar.
-
timetable.timetable.
load_timetable
(calendar_data, clip_start, clip_end, tag_pat=re.compile('\\[([^]]*)\\] *'))[source]¶ Loads and tags all events from the calendar files in the calendar_files dictionary. The keys in calendar_files are passed into
annotate_tags()
as emptytag. The values in calendar_files are filenames to iCal calendars. All events are clipped to clip_start and clip_end.
-
timetable.timetable.
merge_intersection
(entries, start, end)[source]¶ Generates a non-overlapping timetable from entries. start and end limit the timespan for the intersection generation. The resulting timetable contains entry dictionaries with the single key
entries
, whose value is the list of merged entries.
-
timetable.timetable.
merge_intersections
(timetable)[source]¶ Generates a timetable with merged intersection of entries in timetable. The resulting timetable will only contain entries with a single key
entries
, whose value is the list of the merged entries.