Implement a very basic, description-only import

This commit is contained in:
Matt Snider 2018-11-07 00:50:00 +01:00
parent ba13b4e915
commit 82cc4bc04b
3 changed files with 92 additions and 0 deletions

40
.gitignore vendored Normal file
View File

@ -0,0 +1,40 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Environments
venv/

48
migrate.py Normal file
View File

@ -0,0 +1,48 @@
import click
from taskw import TaskWarrior
from todoist.api import TodoistAPI
todoist = None
taskwarrior = None
""" CLI Commands """
@click.group()
@click.option('--todoist-api-key', envvar='TODOIST_API_KEY', required=True)
def cli(todoist_api_key):
# Just do some initialization
global todoist
global taskwarrior
todoist = TodoistAPI(todoist_api_key)
taskwarrior = TaskWarrior()
@cli.command()
@click.option('-i', '--interactive', default=False)
def migrate(interactive):
important('Starting migration...')
# todoist.sync()
tasks = todoist.items.all()
info(f'Todoist tasks: {len(todoist.items.all())}')
for task in todoist.items.all():
tid = task['id']
name = task['content']
info(f'Importing task #{tid}: {name}')
taskwarrior.task_add(name)
""" Utils """
def important(msg):
click.echo(click.style(msg, fg='blue', bold=True))
def info(msg):
click.echo(msg)
""" Entrypoint """
if __name__ == '__main__':
cli()

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
Click==7.0
taskw==1.2.0
todoist-python==7.0.18