mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Handle project name
This commit is contained in:
parent
3fa28b44d1
commit
2e1b51bdbf
18
migrate.py
18
migrate.py
@ -29,23 +29,25 @@ def migrate(interactive, no_sync):
|
||||
tasks = todoist.items.all()
|
||||
important(f'Starting migration of {len(tasks)}...')
|
||||
for task in todoist.items.all():
|
||||
if interactive and not click.confirm(f"Import '{task['content']}'?"):
|
||||
tid = task['id']
|
||||
name = task['content']
|
||||
project = todoist.projects.get_by_id(task['project_id'])
|
||||
|
||||
if interactive and not click.confirm(f"Import '{name}'?"):
|
||||
continue
|
||||
|
||||
add_task(task)
|
||||
add_task(tid, name, project)
|
||||
|
||||
|
||||
def add_task(todoist_task):
|
||||
def add_task(tid, name, project):
|
||||
"""Add a taskwarrior task from todoist task
|
||||
|
||||
Returns the taskwarrior task.
|
||||
"""
|
||||
tid = todoist_task['id']
|
||||
name = todoist_task['content']
|
||||
|
||||
info(f"Importing '{name}' (ID: {tid}) - ", nl=False)
|
||||
project_name = project['name'] if project else None
|
||||
info(f"Importing '{name}' ({project_name}) - ", nl=False)
|
||||
try:
|
||||
tw_task = taskwarrior.task_add(name)
|
||||
tw_task = taskwarrior.task_add(name, project=project_name)
|
||||
except:
|
||||
error('FAILED')
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user