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()
|
tasks = todoist.items.all()
|
||||||
important(f'Starting migration of {len(tasks)}...')
|
important(f'Starting migration of {len(tasks)}...')
|
||||||
for task in todoist.items.all():
|
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
|
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
|
"""Add a taskwarrior task from todoist task
|
||||||
|
|
||||||
Returns the taskwarrior task.
|
Returns the taskwarrior task.
|
||||||
"""
|
"""
|
||||||
tid = todoist_task['id']
|
project_name = project['name'] if project else None
|
||||||
name = todoist_task['content']
|
info(f"Importing '{name}' ({project_name}) - ", nl=False)
|
||||||
|
|
||||||
info(f"Importing '{name}' (ID: {tid}) - ", nl=False)
|
|
||||||
try:
|
try:
|
||||||
tw_task = taskwarrior.task_add(name)
|
tw_task = taskwarrior.task_add(name, project=project_name)
|
||||||
except:
|
except:
|
||||||
error('FAILED')
|
error('FAILED')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user