kindle manager
This commit is contained in:
@@ -73,6 +73,8 @@ b['1']['2'] = {'3':1} # OK
|
||||
and generator rcc binnay file, must kmanapp\_rc.py
|
||||
command: pyside2-rcc -binary kmanapp.qrc -o kmanapp\_rc.py
|
||||
- use QTime to check kindle kindle is connected or not
|
||||
- implement table model which inherited from QAbstractTableModel, so
|
||||
we can use **panda data structure**
|
||||
|
||||
# feature plan
|
||||
## 20200528
|
||||
|
||||
13
kman.py
13
kman.py
@@ -63,7 +63,8 @@ SYS = 'WIN' if platform.system()=='Windows' else \
|
||||
# some constants
|
||||
LASTLINE = '=========='
|
||||
NTPREF = '--CG注:'
|
||||
CLIPPATH = './My Clippings.txt' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
CLIPFN = 'My Clippings.txt'
|
||||
CLIPPATH = './' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
#CLIPPATH = './tclip.txt'
|
||||
OUTPREF = './clip'
|
||||
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
||||
@@ -126,7 +127,7 @@ class kMan:
|
||||
kp = self.get_kindle_path()
|
||||
|
||||
if not kp:
|
||||
s2 = u'Disconnected ({})'.format(CLIPPATH)
|
||||
s2 = u'Disconnected ({})'.format(CLIPPATH+CLIPFN)
|
||||
else:
|
||||
with open(kp+'/system/version.txt' , 'r', encoding='utf8', errors='ignore') as f:
|
||||
s2 = u'Connected ({}) version {}'.format(kp,f.read().strip())
|
||||
@@ -192,8 +193,8 @@ class kMan:
|
||||
|
||||
# parse #1 line
|
||||
aus = au.search(authinfo)
|
||||
bookname = aus.group(1).strip()
|
||||
author = aus.group(2).strip()
|
||||
bookname = aus.group(1).strip().replace(' ','')
|
||||
author = aus.group(2).strip().replace(' ','')
|
||||
section[bookname]['author'] = author
|
||||
|
||||
section['bookname'] = bookname
|
||||
@@ -493,7 +494,7 @@ class kMan:
|
||||
for d in sout.split('\n'):
|
||||
if 'Kindle' in d: return d.split('\s+')[0]
|
||||
elif os.name == 'posix': # mac os
|
||||
if sout: return('/Volumes/Kindle')
|
||||
if sout: return('/Volumes/Kindle/')
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -512,7 +513,7 @@ class kMan:
|
||||
|
||||
return False
|
||||
|
||||
def import_clips(self, fp=CLIPPATH):
|
||||
def import_clips(self, fp=(CLIPPATH+CLIPFN)):
|
||||
"""import clips from local file or kindle
|
||||
4 lines for each section seperated with '======='
|
||||
so read 4 lines before '======='
|
||||
|
||||
10
kmanapp.py
10
kmanapp.py
@@ -142,11 +142,15 @@ class kmanWindow(QMainWindow):
|
||||
info = re.split(r'\s+',item.text())[0]
|
||||
self.filter_data = self.km.filter_clips(self.books, info, 2)
|
||||
|
||||
'''
|
||||
data = self.convert_to_panda(self.filter_data)
|
||||
del self.ui.tablemodel
|
||||
self.ui.tablemodel = nTableModel(data)
|
||||
self.ui.tableView.verticalHeader().hide()
|
||||
self.ui.tableView.setModel(self.ui.tablemodel)
|
||||
'''
|
||||
|
||||
self.refresh_ui_component()
|
||||
|
||||
def table_item_clicked(self, index):
|
||||
if index.isValid():
|
||||
@@ -211,13 +215,13 @@ class kmanWindow(QMainWindow):
|
||||
self.messagebox(ico=2, info='\n\n kindle is not connected')
|
||||
return 0
|
||||
|
||||
self.books = self.km.import_clips(self.km.get_kindle_path())
|
||||
self.books = self.km.import_clips(fp+'documents/'+CLIPFN)
|
||||
self.filter_data = self.km.filter_clips(self.books)
|
||||
|
||||
status = self.km.status_info()
|
||||
self.refresh_ui_component()
|
||||
|
||||
print(bks)
|
||||
#print(bks)
|
||||
|
||||
def import_local(self):
|
||||
fn, ft = QFileDialog.getOpenFileName(self,
|
||||
@@ -312,7 +316,7 @@ class kmanWindow(QMainWindow):
|
||||
pass
|
||||
|
||||
def refresh(self):
|
||||
import_kindle(self.books)
|
||||
self.import_kindle(self.books)
|
||||
print("call slot refresh()")
|
||||
pass
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ from kman import *
|
||||
class TestKman(unittest2.TestCase):
|
||||
# initial
|
||||
def setUp(self):
|
||||
CLIPPATH = './test.data'
|
||||
OUTPREF = './test.clip'
|
||||
LOG2FILE = 1
|
||||
DELIMITER= '|'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user