Skip to content

Commit c139d7c

Browse files
committed
add option lib archiver(read only for now),
compilation script updated, scripts installers modified: - version with python installer deleted - version light updated - creation version python compiled
1 parent e9f713e commit c139d7c

33 files changed

+457
-264
lines changed

.gitignore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ Thumbs.db
6666
# Python byte code
6767
*.pyc
6868
*.pyo
69+
*.pyd
6970

7071
# Binaries
7172
# --------
7273
*.dll
7374
*.exe
7475

76+
77+
# Binaries
7578
/tmp
7679
/*/tmp
7780
/data
7881
/tools/7zip/*
7982
/tools/poppler/*
80-
/database.db
81-
/home/home_ui.py
82-
/tools/fool.txt
83-
/tests/home_window.pyw
83+
/*.db
84+
*_ui.py
85+
/tools/*.txt
8486
/installer/python/*
85-
/ressources/fonts/_old/*
86-
8787
/test/*/*

CentralBlockTable.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ def central_block_table_define_slots(self):
3232
sizes = []
3333
print('header_size_policy')
3434
try:
35-
self.header_policy = self.BDD.get_param('home_central_table_header_size_policy')
35+
self.header_policy = self.BDD.get_param('library/headers_size_policy')
3636
if self.header_policy is None or self.header_policy == '':
37-
self.header_policy = self.vars['home_central_table_header_size_policy']
37+
self.header_policy = self.vars['library']['headers_size_policy']
3838
print(self.header_policy)
3939
if self.header_policy in ['ResizeToContents', 'ResizeToContentsAndInteractive']:
4040
self.central_block_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
4141
if self.header_policy == 'Stretch':
4242
self.central_block_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
4343
if self.header_policy == 'UserDefined':
4444
self.central_block_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Interactive)
45-
tx = self.BDD.get_param('home_central_table_header_sizes')
45+
tx = self.BDD.get_param('library/headers_size')
4646
if tx is None or tx == '':
47-
sizes = json.loads(self.vars['home_central_table_header_sizes'])
47+
sizes = json.loads(self.vars['library']['headers_size'])
4848
else:
4949
sizes = json.loads(tx)
5050
print(sizes)
@@ -71,8 +71,8 @@ def central_block_table_get_column_width(self):
7171
i += 1
7272
new_size = json.dumps(sizes)
7373
print(new_size)
74-
self.BDD.set_param('home_central_table_header_sizes', new_size)
75-
self.BDD.set_param('home_central_table_header_size_policy', self.header_policy)
74+
self.BDD.set_param('library/headers_size', new_size)
75+
self.BDD.set_param('library/headers_size_policy', self.header_policy)
7676

7777
except Exception:
7878
""

common/archive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
def inflate(src: str, dest: str):
88
list_args = list() # create list argument for external command execution
9-
list_args.append(env_vars['tools']['7zip'][os.name]['path']) # insert executable path
10-
temp_args = env_vars['tools']['7zip'][os.name]['params_inflate'].split(' ') # create table of raw command arguments
9+
list_args.append(env_vars['tools']['archiver']['path'] + os.sep + env_vars['tools']['archiver'][os.name]['exe']) # insert executable path
10+
temp_args = env_vars['tools']['archiver'][os.name]['params_inflate'].split(' ') # create table of raw command arguments
1111
for var in temp_args: # parse table of raw command arguments
1212
# insert parsed param
1313
list_args.append(var.replace('%input%', src).replace('%output%', dest))
@@ -17,8 +17,8 @@ def inflate(src: str, dest: str):
1717

1818
def deflate(src: str, dest: str):
1919
list_args = list() # create list argument for external command execution
20-
list_args.append(env_vars['tools']['7zip'][os.name]['path']) # insert executable path
21-
temp_args = env_vars['tools']['7zip'][os.name]['params_deflate'].split(' ') # create table of raw command arguments
20+
list_args.append(env_vars['tools']['archiver']['path'] + os.sep + env_vars['tools']['archiver'][os.name]['exe']) # insert executable path
21+
temp_args = env_vars['tools']['archiver'][os.name]['params_deflate'].split(' ') # create table of raw command arguments
2222
for var in temp_args: # parse table of raw command arguments
2323
# insert parsed param
2424
list_args.append(var.replace('%input%', src).replace('%output%', dest))

common/bdd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def dict_factory(cursor, row):
2424

2525
class BDD:
2626
def __init__(self, directory: str = None):
27-
self.settings = PyQt5.QtCore.QSettings("LordKBX Workshop", app_name)
27+
self.settings = PyQt5.QtCore.QSettings(app_editor, app_name)
2828
self.connexion = None
2929
self.cursor = None
3030
self.__directory = self.get_param('library/directory')

common/books.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ def create_epub(title: str, authors: str = None, series: str = None, volume_numb
236236
content = content.replace('{{TITLE}}', title)
237237
content = content.replace('{{UUID}}', creation_uuid)
238238
content = content.replace('{{APP_NAME}}', app_name)
239-
content = content.replace('{{COVER_NAME}}', local_lang['Home']['emptyBookCreation']['Cover'])
240-
content = content.replace('{{CHAPTER1_NAME}}', local_lang['Home']['emptyBookCreation']['Chapter1'])
239+
content = content.replace('{{COVER_NAME}}', local_lang['Library']['emptyBookCreation']['Cover'])
240+
content = content.replace('{{CHAPTER1_NAME}}', local_lang['Library']['emptyBookCreation']['Chapter1'])
241241
file.write(content)
242242

243243
with open(app_user_directory+os.sep+'tmp'+os.sep+'texte'+os.sep+'cover.xhtml', 'w', encoding="utf8") as file:
@@ -256,13 +256,13 @@ def create_epub(title: str, authors: str = None, series: str = None, volume_numb
256256
content = content.replace('{{SERIES}}', '')
257257
if authors is None or authors.strip() == '':
258258
content = content.replace('{{AUTHORS}}', 'UNKWON')
259-
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Home']['emptyBookCreation']['Author'])
259+
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Library']['emptyBookCreation']['Author'])
260260
else:
261261
content = content.replace('{{AUTHORS}}', authors)
262262
if "," in authors or ";" in authors:
263-
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Home']['emptyBookCreation']['Authors'])
263+
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Library']['emptyBookCreation']['Authors'])
264264
else:
265-
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Home']['emptyBookCreation']['Author'])
265+
content = content.replace('{{AUTHORS_LABEL}}', local_lang['Library']['emptyBookCreation']['Author'])
266266
file.write(content)
267267

268268
with open(app_user_directory+os.sep+'tmp'+os.sep+'texte'+os.sep+'ch01.xhtml', 'w', encoding="utf8") as file:
@@ -277,7 +277,7 @@ def create_epub(title: str, authors: str = None, series: str = None, volume_numb
277277
'<div class="block">Duis ullamcorper ipsum vitae tellus auctor ullamcorper. Aenean ultrices egestas neque, sit amet aliquam erat malesuada id. Maecenas venenatis purus gravida urna luctus consequat. Donec posuere, ligula nec feugiat tristique, lectus elit ultrices nisi, ut mollis risus lacus in nisi. Ut auctor lectus sed orci scelerisque, nec pellentesque tellus aliquet. Curabitur nec faucibus urna. Vestibulum congue mattis libero, vel egestas est sodales in. Curabitur tortor felis, tempus ac dictum eu, dictum non metus. Cras molestie lacinia enim, vitae auctor justo laoreet et. Suspendisse nec ullamcorper ligula. Pellentesque feugiat hendrerit velit, et sagittis dui tristique sed. Etiam ex turpis, mollis et enim ut, dapibus tempus neque. Etiam interdum molestie nisl a condimentum. Nulla faucibus ante at lacus posuere, at consectetur nunc egestas.</div>' \
278278
'</body></html>'
279279
content = content.replace('{{LANG}}', local_lang.language)
280-
content = content.replace('{{CHAPTER1_NAME}}', local_lang['Home']['emptyBookCreation']['Chapter1'])
280+
content = content.replace('{{CHAPTER1_NAME}}', local_lang['Library']['emptyBookCreation']['Chapter1'])
281281
file.write(content)
282282

283283
filename = file_name_template\

common/vars.py

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
import os, re
1+
import os, sys, re
22
from PyQt5 import QtCore, QtGui, QtWidgets
33

4+
app_editor = "LordKBX Workshop"
45
app_name = "eBookCollection"
56
app_directory = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
67
app_user_directory = os.path.expanduser('~') + os.sep + app_name
78

9+
10+
def load_path_archiver():
11+
settings = QtCore.QSettings(app_editor, app_name)
12+
path_archiver = None
13+
if os.name == 'nt':
14+
path_archiver = settings.value('archiver_dir', None, str)
15+
if path_archiver is None or path_archiver == '':
16+
if os.name == 'nt':
17+
settings_7zip = QtCore.QSettings('HKEY_CURRENT_USER\\SOFTWARE\\7-Zip', QtCore.QSettings.NativeFormat)
18+
path_archiver = settings_7zip.value('Path', None)
19+
# if path_archiver is None:
20+
# path_archiver = app_directory + os.sep + 'tools' + os.sep + '7zip'
21+
else:
22+
path_archiver = None
23+
else:
24+
path_archiver = None
25+
return path_archiver
26+
27+
828
env_vars = {
929
'tools': {
1030
'poppler': {
@@ -14,9 +34,10 @@
1434
'params_full': '-r 200 -scale-to 1920 -hide-annotations -jpeg -jpegopt quality=92,progressive=y,optimize=y %input% %output%'
1535
}
1636
},
17-
'7zip': {
37+
'archiver': {
38+
'path': load_path_archiver(),
1839
'nt': {
19-
'path': app_directory + os.sep + 'tools' + os.sep + '7zip' + os.sep + '7z.exe',
40+
'exe': '7z.exe',
2041
'params_deflate': 'a -tzip %output% %input%',
2142
'params_inflate': 'x %input% -o%output%'
2243
}
@@ -34,8 +55,10 @@
3455
'title_serie_authors_tags': '%title% - %series% - %authors% - %tags%'
3556
},
3657
'import_file_separator': ' - ',
37-
'home_central_table_header_size_policy': 'UserDefined', # ResizeToContents, ResizeToContentsAndInteractive, Stretch, UserDefined
38-
'home_central_table_header_sizes': '[100, 100, 100, 100, 100]', # list of collumns size
58+
'library': {
59+
'headers_size_policy': 'UserDefined', # ResizeToContents, ResizeToContentsAndInteractive, Stretch, UserDefined
60+
'headers_size': '[100, 100, 100, 100, 100]' # list of collumns size
61+
},
3962
'default_storage': os.path.expanduser('~') + os.sep + app_name + os.sep + 'data',
4063
'default_style': 'Dark',
4164
'default_language': 'auto',
@@ -78,28 +101,40 @@
78101
'styles': { }
79102
}
80103

81-
directory = app_directory + os.sep + "ressources" + os.sep + "cover_patterns"
82-
ext = "png"
83-
for root, directories, files in os.walk(directory, topdown=False):
84-
for name in files:
85-
if re.search("\\.({})$".format(ext), name) is None:
86-
continue
87-
else:
88-
nm = name.replace("."+ext, "")
89-
env_vars['vars']['default_cover']['patterns'].append(nm)
90104

91-
directory = app_directory + os.sep + "ressources" + os.sep + "styles"
92-
ext = "json"
93-
for root, directories, files in os.walk(directory, topdown=False):
94-
for name in files:
95-
if re.search("\\.({})$".format(ext), name) is None:
96-
continue
97-
else:
98-
nm = name.replace("."+ext, "")
99-
fp = open(directory + os.sep + name, "r", encoding="utf8")
100-
content = fp.read()
101-
fp.close()
102-
env_vars['styles'][nm] = eval(
103-
content.replace('{APP_DIR}', app_directory.replace(os.sep, '/'))
104-
.replace('[', '"\\n".join([').replace(']', '])')
105-
)
105+
def load_patterns():
106+
global app_directory, env_vars
107+
directory = app_directory + os.sep + "ressources" + os.sep + "cover_patterns"
108+
ext = "png"
109+
env_vars['vars']['default_cover']['patterns'].clear()
110+
for root, directories, files in os.walk(directory, topdown=False):
111+
for name in files:
112+
if re.search("\\.({})$".format(ext), name) is None:
113+
continue
114+
else:
115+
nm = name.replace("." + ext, "")
116+
env_vars['vars']['default_cover']['patterns'].append(nm)
117+
118+
119+
def load_styles():
120+
global app_directory, env_vars
121+
directory = app_directory + os.sep + "ressources" + os.sep + "styles"
122+
ext = "json"
123+
env_vars['styles'].clear()
124+
for root, directories, files in os.walk(directory, topdown=False):
125+
for name in files:
126+
if re.search("\\.({})$".format(ext), name) is None:
127+
continue
128+
else:
129+
nm = name.replace("." + ext, "")
130+
fp = open(directory + os.sep + name, "r", encoding="utf8")
131+
content = fp.read()
132+
fp.close()
133+
env_vars['styles'][nm] = eval(
134+
content.replace('{APP_DIR}', app_directory.replace(os.sep, '/'))
135+
.replace('[', '"\\n".join([').replace(']', '])')
136+
)
137+
138+
139+
load_patterns()
140+
load_styles()

empty_book.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
class EmptyBookWindow(QDialog):
1212
def __init__(self, parent, bdd):
1313
super(EmptyBookWindow, self).__init__(parent, QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint)
14-
PyQt5.uic.loadUi(app_directory + os.sep + 'home/empty_book.ui'.replace('/', os.sep), self) # Load the .ui file
14+
PyQt5.uic.loadUi(os.path.dirname(os.path.realpath(__file__)) + os.sep + 'empty_book.ui'.replace('/', os.sep), self) # Load the .ui file
1515

1616
lng = parent.lang
1717
self.BDD = bdd
1818
style = self.BDD.get_param('style')
1919

2020
self.setStyleSheet(env_vars['styles'][style]['QDialog'])
21-
self.setWindowTitle(lng['Home/emptyBooks/WindowTitle'])
21+
self.setWindowTitle(lng['Library/emptyBooks/WindowTitle'])
2222

23-
self.number_label.setText(lng['Home/emptyBooks/Number'])
24-
self.authors_label.setText(lng['Home/emptyBooks/Authors'])
25-
self.serie_label.setText(lng['Home/emptyBooks/Series'])
26-
self.name_label.setText(lng['Home/emptyBooks/Name'])
27-
self.format_label.setText(lng['Home/emptyBooks/Format'])
28-
self.serie_volume_label.setText(lng['Home/emptyBooks/SeriesVolume'])
23+
self.number_label.setText(lng['Library/emptyBooks/Number'])
24+
self.authors_label.setText(lng['Library/emptyBooks/Authors'])
25+
self.serie_label.setText(lng['Library/emptyBooks/Series'])
26+
self.name_label.setText(lng['Library/emptyBooks/Name'])
27+
self.format_label.setText(lng['Library/emptyBooks/Format'])
28+
self.serie_volume_label.setText(lng['Library/emptyBooks/SeriesVolume'])
2929

3030
self.number_spin_box.setValue(1)
3131
self.serie_volume_spin_box.setValue(1.0)

0 commit comments

Comments
 (0)