mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Handle priority: (1-4) -> LMH
This commit is contained in:
parent
56dfffbb80
commit
4b1cb268a1
11
migrate.py
11
migrate.py
@ -32,6 +32,7 @@ def migrate(interactive, no_sync):
|
|||||||
tid = task['id']
|
tid = task['id']
|
||||||
name = task['content']
|
name = task['content']
|
||||||
project = todoist.projects.get_by_id(task['project_id'])['name']
|
project = todoist.projects.get_by_id(task['project_id'])['name']
|
||||||
|
priority = taskwarrior_priority(task['priority'])
|
||||||
tags = [
|
tags = [
|
||||||
todoist.labels.get_by_id(l_id)['name']
|
todoist.labels.get_by_id(l_id)['name']
|
||||||
for l_id in task['labels']
|
for l_id in task['labels']
|
||||||
@ -40,17 +41,17 @@ def migrate(interactive, no_sync):
|
|||||||
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, tags)
|
add_task(tid, name, project, tags, priority)
|
||||||
|
|
||||||
|
|
||||||
def add_task(tid, name, project, tags):
|
def add_task(tid, name, project, tags, priority):
|
||||||
"""Add a taskwarrior task from todoist task
|
"""Add a taskwarrior task from todoist task
|
||||||
|
|
||||||
Returns the taskwarrior task.
|
Returns the taskwarrior task.
|
||||||
"""
|
"""
|
||||||
info(f"Importing '{name}' ({project}) - ", nl=False)
|
info(f"Importing '{name}' ({project}) - ", nl=False)
|
||||||
try:
|
try:
|
||||||
tw_task = taskwarrior.task_add(name, project=project, tags=tags)
|
tw_task = taskwarrior.task_add(name, project=project, tags=tags, priority=priority)
|
||||||
except:
|
except:
|
||||||
error('FAILED')
|
error('FAILED')
|
||||||
else:
|
else:
|
||||||
@ -72,6 +73,10 @@ def success(msg, **kwargs):
|
|||||||
def error(msg, **kwargs):
|
def error(msg, **kwargs):
|
||||||
click.echo(click.style(msg, fg='red', bold=True))
|
click.echo(click.style(msg, fg='red', bold=True))
|
||||||
|
|
||||||
|
PRIORITIES = {1: None, 2: 'L', 3: 'M', 4: 'H'}
|
||||||
|
def taskwarrior_priority(priority):
|
||||||
|
"""Converts a priority from Todiost (1-4) to taskwarrior (None, L, M, H) """
|
||||||
|
return PRIORITIES[priority]
|
||||||
|
|
||||||
""" Entrypoint """
|
""" Entrypoint """
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user