kindle manager

This commit is contained in:
gavin
2020-06-13 10:35:17 +08:00
parent 48e7593adc
commit 6423711484
7 changed files with 149 additions and 29 deletions

35
x Normal file
View File

@@ -0,0 +1,35 @@
''' move to class kmanWindow kmanapp.py
XXX
def export_notes(self, bks, fnpref, ft='MD'):
"""format output and write to file
markdown format:
TYPE | bookname | author | marktime | content
--|--|--|--|--
xx|xx|xx|xx|xx
CSV format:
TYPE,bookname,author,marktime,content
xx,xx,xx,xx,xx
marktime: 20200403 PM 3:0:3 星期五
Args:
bks: books dict
f: can be 'MD'/'JSON'/'CSV'
Returns: special format of 'bks' dict
"""
suff = {'MD':'.md','CSV':'.csv','JSON':'.json'}
op = fnpref+suff[ft]
with open(op, 'w', encoding='utf8', errors='ignore') as fw:
if ft=='JSON':
fw.write(json.dumps(bks, indent=4, sort_keys=True, ensure_ascii=False))
elif ft in ['MD','CSV']:
for s in self.format_note_data(bks, ft):
fw.write(s)
fw.write('\n')
else:
fw.write(json.dumps(bks)) # only for load back
'''