From 0017b074f01062a7a85f6823e3232f3745b8669d Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Mon, 19 Oct 2020 23:48:23 +1000 Subject: [PATCH] finished --- .gitignore | 1 + tiddlers.json | 4 ++-- tiddly2kitaab.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 tiddly2kitaab.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b95e682 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +jrnl/ diff --git a/tiddlers.json b/tiddlers.json index af8eb01..13943bc 100644 --- a/tiddlers.json +++ b/tiddlers.json @@ -1,7 +1,7 @@ [ { "text": "Okay now with time! ", - "title": "10-February-2018 at 20h11'11''", + "title": "10-February-2018 at 20:11", "tags": "Journal", "modified": "20180210091136675", "created": "20180210091111591" @@ -2904,4 +2904,4 @@ "title": "Draft of '3rd May 2020 at 23:08'", "modified": "20200507092155456" } -] \ No newline at end of file +] diff --git a/tiddly2kitaab.py b/tiddly2kitaab.py new file mode 100644 index 0000000..defcd1f --- /dev/null +++ b/tiddly2kitaab.py @@ -0,0 +1,42 @@ +import json + +def createFile(tiddler): + try: + created = tiddler['created'] + except KeyError: + print("!!! BLANK TIDDLER !!!") + print(tiddler) + return + title = tiddler['title'] + text = tiddler['text'] + modified = tiddler['modified'] + tags = tiddler['tags'] + + # create the filename + filename = created[2:8] # YYMMDD + filename = filename + "-" + hour = title[-5:].replace(':', '') + filename = filename+hour+'.wiki' + + # handle tags + allTags = ':' + for t in tags: + allTags = allTags + t + ':' + + # handle date + date = created[:4] + '-' + created[4:6] + '-' + created[6:8] + ' ' + hour + + # create write list + writeList = ['%title {title}', allTags, '%date {date}', '', text] + + # create and write the file + file = open('./jrnl/'+filename, 'w+') + file.writelines(writeList) + file.close() + +def createFiles(tiddlers): + for t in tiddlers: + createFile(t) + +tid = json.load(open('tiddlers.json')) +createFiles(tid)