kindle manager

This commit is contained in:
gavin
2020-06-29 17:01:30 +08:00
parent c8447b6859
commit 069e12dc4a
8 changed files with 1987 additions and 2125 deletions

17
kman.py
View File

@@ -61,17 +61,28 @@ books_data =
SYS = 'WIN' if platform.system()=='Windows' else \
('LINUX' if platform.system()=='LINUX' else 'MAC')
frozen = 'not'
#CURRPATH = os.path.dirname(os.path.realpath(sys.argv[0]))
CURRPATH = ''
if getattr(sys, 'frozen', False):
# we are running in a bundle
frozen = 'ever so'
CURRPATH = sys._MEIPASS
os.chdir(CURRPATH)
else:
# we are running in a normal Python environment
CURRPATH = os.path.dirname(os.path.abspath(__file__))
# some constants
LASTLINE = '=========='
NTPREF = '--CG注:'
CLIPFN = 'My Clippings.txt'
WORDFN = 'vocab.db'
CURRPATH = os.path.dirname(os.path.realpath(sys.argv[0]))
OUTPREF = os.path.join(CURRPATH,'CLIP')
DEBUG = 1 # 0 - INFO; 1 - DEBUG
LOG2FILE = 1 # 0 - to stdio; 1 - to file
LOGFILE = 'log'
DELIMITER= '|'
LOGFILE = os.path.join(CURRPATH,'log')
BACKUPFOLDER = os.path.join(CURRPATH,'backup')
BACKUPNOTEFN = os.path.join(BACKUPFOLDER,'bk.note.data') # kindle notes
BACKUPWORDFN = os.path.join(BACKUPFOLDER,'bk.word.data') # kindle words
@@ -834,7 +845,7 @@ if __name__=='__main__':
km.add_note_to_highlight(books)
# test dict json convert
with open(os.path.join(CURRPATH,'xx', 'w'), encoding='utf8', errors='ignore') as fw:
with open(os.path.join(CURRPATH,'xx'), 'w', encoding='utf8', errors='ignore') as fw:
fw.write(km.dict2json(books))
if km.json2dict(os.path.join(CURRPATH,'xx'))==books: print( 'test OK')