43 lines
1,007 B
Python
43 lines
1,007 B
Python
|
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)
|