kindle manager
This commit is contained in:
17
kman.py
17
kman.py
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user