mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Handle labels (tags)
This commit is contained in:
parent
2e1b51bdbf
commit
56dfffbb80
17
migrate.py
17
migrate.py
@ -31,28 +31,31 @@ def migrate(interactive, no_sync):
|
|||||||
for task in todoist.items.all():
|
for task in todoist.items.all():
|
||||||
tid = task['id']
|
tid = task['id']
|
||||||
name = task['content']
|
name = task['content']
|
||||||
project = todoist.projects.get_by_id(task['project_id'])
|
project = todoist.projects.get_by_id(task['project_id'])['name']
|
||||||
|
tags = [
|
||||||
|
todoist.labels.get_by_id(l_id)['name']
|
||||||
|
for l_id in task['labels']
|
||||||
|
]
|
||||||
|
|
||||||
if interactive and not click.confirm(f"Import '{name}'?"):
|
if interactive and not click.confirm(f"Import '{name}'?"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
add_task(tid, name, project)
|
add_task(tid, name, project, tags)
|
||||||
|
|
||||||
|
|
||||||
def add_task(tid, name, project):
|
def add_task(tid, name, project, tags):
|
||||||
"""Add a taskwarrior task from todoist task
|
"""Add a taskwarrior task from todoist task
|
||||||
|
|
||||||
Returns the taskwarrior task.
|
Returns the taskwarrior task.
|
||||||
"""
|
"""
|
||||||
project_name = project['name'] if project else None
|
info(f"Importing '{name}' ({project}) - ", nl=False)
|
||||||
info(f"Importing '{name}' ({project_name}) - ", nl=False)
|
|
||||||
try:
|
try:
|
||||||
tw_task = taskwarrior.task_add(name, project=project_name)
|
tw_task = taskwarrior.task_add(name, project=project, tags=tags)
|
||||||
except:
|
except:
|
||||||
error('FAILED')
|
error('FAILED')
|
||||||
else:
|
else:
|
||||||
success('OK')
|
success('OK')
|
||||||
return tw_task
|
return tw_task
|
||||||
|
|
||||||
|
|
||||||
""" Utils """
|
""" Utils """
|
||||||
|
Loading…
Reference in New Issue
Block a user