Initial commit

This commit is contained in:
2020-06-07 19:09:03 +01:00
commit 3d4a126686
4 changed files with 114 additions and 0 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"python.linting.enabled": true
}

7
LICENSE Normal file
View File

@@ -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.

17
README.md Normal file
View File

@@ -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.

87
nirvana-to-everdo.py Normal file
View File

@@ -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,
}))