diff options
author | Tobias Brox <t@tobixen.no> | 2015-05-04 00:45:44 +0200 |
---|---|---|
committer | Tobias Brox <t@tobixen.no> | 2015-05-04 00:45:44 +0200 |
commit | 2889e3eb58c837ab0bf68517aba2eb7257f11cff (patch) | |
tree | 78eeeb94d484eb9958f5465bd1ed12f4baaa4a08 /calendar-cli.py | |
parent | da1fcd5f9cc4f64795e28a9eeb2be7125541d24a (diff) | |
download | calendar-cli-2889e3eb58c837ab0bf68517aba2eb7257f11cff.zip |
new feature: hide parent task if we need to work on children tasks (think of parent as dependent on the children to be done)
Diffstat (limited to 'calendar-cli.py')
-rwxr-xr-x | calendar-cli.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/calendar-cli.py b/calendar-cli.py index 636e3bc..8380f2f 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -377,6 +377,20 @@ def todo_select(caldav_conn, args): for attr in vtodo_txt_one + vtodo_txt_many: ## TODO: now we have _exact_ match on items in the the array attributes, and substring match on items that cannot be duplicated. Does that make sense? Probably not. if getattr(args, attr): tasks = [x for x in tasks if hasattr(x.instance.vtodo, attr) and getattr(args, attr) in getattr(x.instance.vtodo, attr).value] + if args.hide_parents: + tasks_by_uid = {} + for task in tasks: + tasks_by_uid[task.instance.vtodo.uid.value] = task + for task in tasks: + if hasattr(task.instance.vtodo, 'related_to'): + uid = task.instance.vtodo.uid.value + rel_uid = task.instance.vtodo.related_to.value + rel_type = task.instance.vtodo.related_to.params.get('RELTYPE', 'PARENT') + if rel_type == 'CHILD' and rel_uid in tasks_by_uid and uid in tasks_by_uid: + del tasks_by_uid[uid] + if rel_type == 'PARENT' and rel_uid in tasks_by_uid: + del tasks_by_uid[rel_uid] + tasks = [x for x in tasks if x.instance.vtodo.uid.value in tasks_by_uid] if args.top+args.limit: tasks = tasks[args.offset+args.offsetn:args.top+args.limit+args.offset+args.offsetn] elif args.offset+args.offsetn: @@ -581,6 +595,7 @@ def main(): todo_parser.add_argument('--offsetn', type=int, default=0) todo_parser.add_argument('--limit', type=int, default=0) todo_parser.add_argument('--todo-uid') + todo_parser.add_argument('--hide-parents', help='Hide the parent if you need to work on children tasks first (parent task depends on children tasks to be done first)', action='store_true') for attr in vtodo_txt_one + vtodo_txt_many: todo_parser.add_argument('--'+attr, help="for filtering tasks") |