commit 3d4a12668624dbf28aa2dd369a329d4d48d42b9b Author: Andrew Williams Date: Sun Jun 7 19:09:03 2020 +0100 Initial commit diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f2d90cb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.enabled": true +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ede9293 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2020 Andrew Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..60a17ae --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# NirvanaHQ to EverDo + +A simple script to convert a NirvanaHQ JSOn export into the Everdo JSON format. + +## Requirements + +This script has been tested on Python 3.8.3, included in the current version of Windows 10. The script should support any version of Python from v2.7 onwards due to the limited use of Py3 features. + +## Usage + +Run ```nirvana-to-everdo.py``` with your Nirvana JSON export, and pipe the output to a a filename you want + +``` +$ nirvana-to-everdo.py nirvana.json > everdo.json +``` + +When completed, import the resulting file with Everdo's import function. \ No newline at end of file diff --git a/nirvana-to-everdo.py b/nirvana-to-everdo.py new file mode 100644 index 0000000..8f4392e --- /dev/null +++ b/nirvana-to-everdo.py @@ -0,0 +1,87 @@ +#!/usr/env python +import sys +import json +import uuid +import datetime +import time + +with open(sys.argv[1], 'r') as fobj: + data = json.load(fobj) + +items = [] +tags = [] + +def get_or_create_tag(tag_name): + for tag in tags: + if tag_name == tag['title']: + return tag['id'] + tag_id = str(uuid.uuid4()) + tags.append({ + 'id': tag_id, + 'title': tag_name, + 'type': 'l', + }) + return tag_id + +for item in data: + result = { + 'id': item['id'].replace('-', ''), + 'title': item['name'], + 'created_on': int(item['created']),\ + 'note': item['note'], + 'tags': [], + } + + # Set type + TYPE_LOOKUP = { + '0': 'a', + '1': 'p', + '2': 'n', + '3': 'l', + } + result['type'] = TYPE_LOOKUP[item['type']] + + # State + STATE_LOOKUP = { + '0': 'a', + '1': 'a', + '4': 'm', + '6': 'd', + '7': 'r', + '9': 's', + '10': 'a', + '11': 'a', + } + result['list'] = STATE_LOOKUP[item['state']] + + # Completed + if int(item['completed']) > 0: + result['completed_on'] = int(item['completed']) + + # Parent ID + if item['parentid'] != '': + result['parent_id'] = item['parentid'].replace('-', '') + + # Due Date + if item['duedate'] and int(item['duedate']) > 0: + result['due_date'] = int(time.mktime(datetime.datetime.strptime(item['duedate'], '%Y%m%d').timetuple())) + + # Estimated Time + if item['etime'] and int(item['etime']) > 0: + result['time'] = int(item['etime']) + + # Set Energy + if item['energy'] and int(item['energy']) > 0: + result['energy'] = int(item['energy']) + + # Add tags + item_tags = [x for x in item['tags'].split(',') if x != ''] + for item_tag in item_tags: + result['tags'].append(get_or_create_tag(item_tag)) + + items.append(result) + +sys.stdout.write(json.dumps({ + 'items': items, + 'tags': tags, +})) \ No newline at end of file