Skip to content

Commit

Permalink
2.2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
noembryo committed Oct 5, 2024
1 parent 9a17320 commit 053c7fa
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 111 deletions.
64 changes: 32 additions & 32 deletions images.qrc
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/stuff">
<file alias='view-highlights.png'>stuff/view-highlights.png</file>
<file alias='file_exists.png'>stuff/file_exists.png</file>
<file alias='db.png'>stuff/db.png</file>
<file alias='db_add.png'>stuff/db_add.png</file>
<file alias='files_view.png'>stuff/files_view.png</file>
<file alias='files_delete.png'>stuff/files_delete.png</file>
<file alias='paypal.png'>stuff/paypal.png</file>
<file alias='folder_reader.png'>stuff/folder_reader.png</file>
<file alias='filter.png'>stuff/filter.png</file>
<file alias='db_compact.png'>stuff/db_compact.png</file>
<file alias='file_missing.png'>stuff/file_missing.png</file>
<file alias='label_green.png'>stuff/label_green.png</file>
<file alias='view-sync.png'>stuff/view-sync.png</file>
<file alias='trash.png'>stuff/trash.png</file>
<file alias='db_open.png'>stuff/db_open.png</file>
<file alias='files_add.png'>stuff/files_add.png</file>
<file alias='wait.gif'>stuff/wait.gif</file>
<file alias='paypal76.png'>stuff/paypal76.png</file>
<file alias='file_edit.png'>stuff/file_edit.png</file>
<file alias='logo64.png'>stuff/logo64.png</file>
<file alias='refresh16.png'>stuff/refresh16.png</file>
<file alias='books.png'>stuff/books.png</file>
<file alias='view_books.png'>stuff/view_books.png</file>
<file alias='files_merge.png'>stuff/files_merge.png</file>
<file alias='power32gray.png'>stuff/power32gray.png</file>
<file alias='del.png'>stuff/del.png</file>
<file alias='delete.png'>stuff/delete.png</file>
<file alias='font.ttf'>stuff/font.ttf</file>
<file alias='paypal76.png'>stuff/paypal76.png</file>
<file alias='folder_open.png'>stuff/folder_open.png</file>
<file alias='power32red.png'>stuff/power32red.png</file>
<file alias='prefs.png'>stuff/prefs.png</file>
<file alias='wait.gif'>stuff/wait.gif</file>
<file alias='delete.png'>stuff/delete.png</file>
<file alias='copy.png'>stuff/copy.png</file>
<file alias='calendar.png'>stuff/calendar.png</file>
<file alias='logo.png'>stuff/logo.png</file>
<file alias='trans32.png'>stuff/trans32.png</file>
<file alias='label_green.png'>stuff/label_green.png</file>
<file alias='paypal.png'>stuff/paypal.png</file>
<file alias='folder_reader.png'>stuff/folder_reader.png</file>
<file alias='folder_open.png'>stuff/folder_open.png</file>
<file alias='view-sync.png'>stuff/view-sync.png</file>
<file alias='sort.png'>stuff/sort.png</file>
<file alias='add.png'>stuff/add.png</file>
<file alias='del.png'>stuff/del.png</file>
<file alias='logo.png'>stuff/logo.png</file>
<file alias='file_missing.png'>stuff/file_missing.png</file>
<file alias='db.png'>stuff/db.png</file>
<file alias='db_add.png'>stuff/db_add.png</file>
<file alias='db_compact.png'>stuff/db_compact.png</file>
<file alias='file_exists.png'>stuff/file_exists.png</file>
<file alias='calendar.png'>stuff/calendar.png</file>
<file alias='sync.png'>stuff/sync.png</file>
<file alias='description.png'>stuff/description.png</file>
<file alias='refresh16.png'>stuff/refresh16.png</file>
<file alias='file_save.png'>stuff/file_save.png</file>
<file alias='sync.png'>stuff/sync.png</file>
<file alias='books.png'>stuff/books.png</file>
<file alias='add.png'>stuff/add.png</file>
<file alias='files_view.png'>stuff/files_view.png</file>
<file alias='filter.png'>stuff/filter.png</file>
<file alias='trash.png'>stuff/trash.png</file>
<file alias='files_merge.png'>stuff/files_merge.png</file>
<file alias='db_open.png'>stuff/db_open.png</file>
<file alias='view-highlights.png'>stuff/view-highlights.png</file>
<file alias='trans32.png'>stuff/trans32.png</file>
<file alias='logo64.png'>stuff/logo64.png</file>
<file alias='power32gray.png'>stuff/power32gray.png</file>
<file alias='files_add.png'>stuff/files_add.png</file>
<file alias='view_books.png'>stuff/view_books.png</file>
<file alias='files_delete.png'>stuff/files_delete.png</file>
</qresource>
</RCC>
98 changes: 49 additions & 49 deletions images_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,49 +190,6 @@
D\x7f\x13\x9b8\x16\xfc\xfa\xee\xfa\xd9\x7f\xcf\xff\x05=\
JV/\x95\xeb\x8c\xa7\x00\x00\x00\x00IEND\xae\
B`\x82\
\x00\x00\x02\x89\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xffa\
\x00\x00\x00\x04gAMA\x00\x00\xaf\xc87\x05\x8a\xe9\
\x00\x00\x00\x19tEXtSoftware\
\x00Adobe ImageRead\
yq\xc9e<\x00\x00\x02\x1bIDAT8\xcb\x8d\
S\xcfk\x13Q\x10\x9e\xfdA\xe9\xda\xd4C\xba\xbb\xf1\
\x90\xf4(\x85\xa2\xe0\xa9\xe4T\x10\x11=\x0aB\xf0P\
l\x0f\xed\xa9\xff\x81\x08E\xe8\xc9\xab\x82\x97\xb2\x85\x1e\
J\x0e\xbd\x88\xa6R\x94\xe8E<\x88I[l\x96\x22\
&\xa4,$-A\xaa\xc6\xfc\xd8\xdd\xb7\xce\xbc\xed\xbe\
l\xe8%\x8f\x1d\xf6\xbd\xd9\xf9f\xbe7\xdf\xac\x14\x04\
\x01\x94\xcb\xe5{\x7f\xde\xbf\xdc\xf5Z\x0ex\xcd*\xdc\
\xb5\xec9\x18m\x9dJ\xa5R\xe9\xa6\xef\xfb\x9f\x99\xdb\
\x9dP\xc0\x87\xb3W+pg\xe3\xfbHhUU\xe7\
\xd4|>og\xb3\xd9\xd5\xf1\xa3\x82\x95\x98Bo\x00\
\xe0\xba\xeeP c\x0c\x88i\xfc\xaciZ\x98$\x97\
\xcb\xcd \x83\x17\xcc\x5c\x00\x05<\xf8\xfd\xa9x\xa9\x92\
,\xcb\x1c\x14-I\x92DB\xc1`\xec\xa0`M\x9a\
\xe8da\x00\xadg;M \x1c\x85r\x00\xe3\x0f\xac\
=\xd4\x07\xd7\x10\x0c\x0cd yp\xfe\xe1\xa3H@\
\xe0\xd9\x8cv\x91 \xb4\xfdZ\x9b\x7fC\xcc0\x03u\
\xff\xaduU\x0fx%\x91\x00\xf7\x87\xb5\x7f\xbcj\xc0\
\xf0\x1b\xf3\xd1\x17\xf6\x00\xaf\xc5\xef4P\xa1\x8f* \
\x03\xe7\xf92\xdc\xcf\x1f\xf1D\xf1{\xd3\xd9\xf3<\xe1\
Gk'\x93\xc9\xf9\x01\x83oo\xacI#\xe4\x19\x05\
=\xd9n\xe0\xdbG\xba\x01\xf8\xc1\x85\x12\xa8\xd0Z\xce\
$\x06\x13\x98W\x89\xf5\xe01W\xe1\xd7^Qtz\
\xfd\xd15\x0e\x22C\xcd\x05\x9bn\xb7\x0b\xd5j\x15\x14\
E\x91eb\xe08\xcej\xb3\xb0\x09\x7f\xbfn\x01\x16\
\x14\x12ErE\x0d\x8b\xc0\x95J\x05R\xa9\x14\xf9Y\
\x8c\xc1\x22\xc8\xc8\xa0\xb5[\x8c\xa9\xc0\x84\x91\xaf\xd3\xe9\
\x80m\xdb\x90\xc9d@\xd7\xf5a\x15\xe4/\xaf\xad\x84\
\x89M\xf3/O 1\xa0\xca\x04N\xa7\xd3`\x18\xc6\
`\xa8\xe2*\x10\x83\xda\xd3%x\xb0\xf7\x83\x83\x09H\
\x9d\xef\xf5z\xd0h4xU\xd34\xe3\x13\x19\xfe\x0b\
\x18t\xe3V\xe5\xdd\xcf+I\x8d\x0f\x0b5\x88\x80d\
\x11\x0b\x1agJR\xaf\xd7\xf9\xbe\xdf\xef\x87I\xa2\x86\
-]\x9f\x9a\x9fN\x8c\xddv\xda\xee\xc9\xc6q\xeb`\
\xd4\xdf\xf9?\xbb\xea|\xd5>\xc8\xb6\x95\x00\x00\x00\x00\
IEND\xaeB`\x82\
\x00\x00+\xe4\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
Expand Down Expand Up @@ -938,6 +895,49 @@
R\x22\x9f\xd8A\xa1\x01\x19\xe4!\x06\x00\x04\x18\x00\xc7\
9:\x94\x82:\x9d>\x00\x00\x00\x00IEND\xae\
B`\x82\
\x00\x00\x02\x89\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xffa\
\x00\x00\x00\x04gAMA\x00\x00\xaf\xc87\x05\x8a\xe9\
\x00\x00\x00\x19tEXtSoftware\
\x00Adobe ImageRead\
yq\xc9e<\x00\x00\x02\x1bIDAT8\xcb\x8d\
S\xcfk\x13Q\x10\x9e\xfdA\xe9\xda\xd4C\xba\xbb\xf1\
\x90\xf4(\x85\xa2\xe0\xa9\xe4T\x10\x11=\x0aB\xf0P\
l\x0f\xed\xa9\xff\x81\x08E\xe8\xc9\xab\x82\x97\xb2\x85\x1e\
J\x0e\xbd\x88\xa6R\x94\xe8E<\x88I[l\x96\x22\
&\xa4,$-A\xaa\xc6\xfc\xd8\xdd\xb7\xce\xbc\xed\xbe\
l\xe8%\x8f\x1d\xf6\xbd\xd9\xf9f\xbe7\xdf\xac\x14\x04\
\x01\x94\xcb\xe5{\x7f\xde\xbf\xdc\xf5Z\x0ex\xcd*\xdc\
\xb5\xec9\x18m\x9dJ\xa5R\xe9\xa6\xef\xfb\x9f\x99\xdb\
\x9dP\xc0\x87\xb3W+pg\xe3\xfbHhUU\xe7\
\xd4|>og\xb3\xd9\xd5\xf1\xa3\x82\x95\x98Bo\x00\
\xe0\xba\xeeP c\x0c\x88i\xfc\xaciZ\x98$\x97\
\xcb\xcd \x83\x17\xcc\x5c\x00\x05<\xf8\xfd\xa9x\xa9\x92\
,\xcb\x1c\x14-I\x92DB\xc1`\xec\xa0`M\x9a\
\xe8da\x00\xadg;M \x1c\x85r\x00\xe3\x0f\xac\
=\xd4\x07\xd7\x10\x0c\x0cd yp\xfe\xe1\xa3H@\
\xe0\xd9\x8cv\x91 \xb4\xfdZ\x9b\x7fC\xcc0\x03u\
\xff\xaduU\x0fx%\x91\x00\xf7\x87\xb5\x7f\xbcj\xc0\
\xf0\x1b\xf3\xd1\x17\xf6\x00\xaf\xc5\xef4P\xa1\x8f* \
\x03\xe7\xf92\xdc\xcf\x1f\xf1D\xf1{\xd3\xd9\xf3<\xe1\
Gk'\x93\xc9\xf9\x01\x83oo\xacI#\xe4\x19\x05\
=\xd9n\xe0\xdbG\xba\x01\xf8\xc1\x85\x12\xa8\xd0Z\xce\
$\x06\x13\x98W\x89\xf5\xe01W\xe1\xd7^Qtz\
\xfd\xd15\x0e\x22C\xcd\x05\x9bn\xb7\x0b\xd5j\x15\x14\
E\x91eb\xe08\xcej\xb3\xb0\x09\x7f\xbfn\x01\x16\
\x14\x12ErE\x0d\x8b\xc0\x95J\x05R\xa9\x14\xf9Y\
\x8c\xc1\x22\xc8\xc8\xa0\xb5[\x8c\xa9\xc0\x84\x91\xaf\xd3\xe9\
\x80m\xdb\x90\xc9d@\xd7\xf5a\x15\xe4/\xaf\xad\x84\
\x89M\xf3/O 1\xa0\xca\x04N\xa7\xd3`\x18\xc6\
`\xa8\xe2*\x10\x83\xda\xd3%x\xb0\xf7\x83\x83\x09H\
\x9d\xef\xf5z\xd0h4xU\xd34\xe3\x13\x19\xfe\x0b\
\x18t\xe3V\xe5\xdd\xcf+I\x8d\x0f\x0b5\x88\x80d\
\x11\x0b\x1agJR\xaf\xd7\xf9\xbe\xdf\xef\x87I\xa2\x86\
-]\x9f\x9a\x9fN\x8c\xddv\xda\xee\xc9\xc6q\xeb`\
\xd4\xdf\xf9?\xbb\xea|\xd5>\xc8\xb6\x95\x00\x00\x00\x00\
IEND\xaeB`\x82\
\x00\x00\x0aV\
\x89\
PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\
Expand Down Expand Up @@ -17059,14 +17059,14 @@
\x03\x03['\
\x00p\
\x00o\x00w\x00e\x00r\x003\x002\x00g\x00r\x00a\x00y\x00.\x00p\x00n\x00g\
\x00\x0f\
\x0f\xe0}G\
\x00f\
\x00i\x00l\x00e\x00_\x00e\x00x\x00i\x00s\x00t\x00s\x00.\x00p\x00n\x00g\
\x00\x0d\
\x02\xc5;\xc7\
\x00f\
\x00i\x00l\x00e\x00_\x00s\x00a\x00v\x00e\x00.\x00p\x00n\x00g\
\x00\x0f\
\x0f\xe0}G\
\x00f\
\x00i\x00l\x00e\x00_\x00e\x00x\x00i\x00s\x00t\x00s\x00.\x00p\x00n\x00g\
\x00\x08\
\x00FX'\
\x00s\
Expand Down Expand Up @@ -17232,7 +17232,7 @@
\x00\x00\x01\x8c\xff@\xe9A\
\x00\x00\x02`\x00\x00\x00\x00\x00\x01\x00\x02\x12%\
\x00\x00\x01\x8c\xff@\xe9C\
\x00\x00\x00X\x00\x00\x00\x00\x00\x01\x00\x00\x0d\xe5\
\x00\x00\x004\x00\x00\x00\x00\x00\x01\x00\x00\x0bX\
\x00\x00\x01\x8c\xff@\xe9?\
\x00\x00\x00\x10\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x8e\x8fs\xdb\xc7\
Expand Down Expand Up @@ -17302,7 +17302,7 @@
\x00\x00\x01\x8c\xff@\xe9H\
\x00\x00\x02(\x00\x00\x00\x00\x00\x01\x00\x01\xcaM\
\x00\x00\x01\x8c\xff@\xe9?\
\x00\x00\x004\x00\x00\x00\x00\x00\x01\x00\x00\x0bX\
\x00\x00\x00T\x00\x00\x00\x00\x00\x01\x00\x007@\
\x00\x00\x01\x8c\xff@\xe9E\
"

Expand Down
30 changes: 20 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


__author__ = "noEmbryo"
__version__ = "2.2.0.0"
__version__ = "2.2.1.0"


class Base(QMainWindow, Ui_Base):
Expand Down Expand Up @@ -3016,8 +3016,12 @@ def save_multi_files(self, dir_path, format_, line_break, space):
continue
highlights = sorted(highlights, key=self.sort_high4write)
try:
save_file(title, authors, highlights, dir_path, format_,
line_break, space, self.custom_template)
args = {"title": title, "authors": authors, "highlights": highlights,
"dir_path": dir_path, "format_": format_,
"line_break": line_break, "space": space,
"custom_template": self.custom_template,
"templ_head": self.templ_head, "templ_body": self.templ_body}
save_file(args)
count += 1
except IOError as err: # any problem when writing (like long filename, etc.)
self.popup(_("Warning!"),
Expand Down Expand Up @@ -3047,8 +3051,11 @@ def save_merged_file(self, filename, format_, line_break, space):
if not highlights: # no highlights
continue
highlights = sorted(highlights, key=self.sort_high4write)
text = get_book_text(title, authors, highlights, format_,
line_break, space, text, self.custom_template)
args = {"title": title, "authors": authors, "highlights": highlights,
"format_": format_, "line_break": line_break, "space": space,
"text": text, "custom_template": self.custom_template,
"templ_head": self.templ_head, "templ_body": self.templ_body}
text = get_book_text(args)
count += 1
if format_ == ONE_HTML:
text += "\n</body>\n</html>"
Expand Down Expand Up @@ -3884,16 +3891,17 @@ def cli_save_multi_files(self, args, files, line_break, space):
format_ = MANY_MD
else:
format_ = MANY_TEXT
sort_by = partial(self.cli_sort, args)
path = abspath(args.output)
for file_ in files:
authors, title, highlights = self.cli_get_item_data(file_, args)
if not highlights: # no highlights
continue
highlights = sorted(highlights, key=partial(self.cli_sort, args))
try:
save_file(title, authors, highlights, path,
format_, line_break, space)
exp_args = {"title": title, "authors": authors, "highlights": highlights,
"dir_path": path, "format_": format_,
"line_break": line_break, "space": space}
save_file(exp_args)
saved += 1
except IOError as err: # any problem when writing (like long filename, etc.)
sys.stdout.write(str(f"Could not save the file to disk!\n{err}"))
Expand Down Expand Up @@ -3935,8 +3943,10 @@ def cli_save_merged_file(self, args, files, line_break, space):
if not highlights: # no highlights
continue
highlights = sorted(highlights, key=partial(self.cli_sort, args))
text = get_book_text(title, authors, highlights, format_,
line_break, space, text)
exp_args = {"title": title, "authors": authors, "highlights": highlights,
"format_": format_, "line_break": line_break, "space": space,
"text": text}
text = get_book_text(exp_args)
saved += 1
if args.html:
text += "\n</body>\n</html>"
Expand Down
50 changes: 30 additions & 20 deletions secondary.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,20 @@ def get_csv_row(data):
return "\t".join(values)


def get_book_text(title, authors, highlights, format_,
line_break, space, text, custom_md=False):
def get_book_text(args):
""" Create the book's contents
"""
title = args["title"]
authors = args["authors"]
highlights = args["highlights"]
format_ = args["format_"]
line_break = args["line_break"]
space = args["space"]
text = args["text"]
custom_template = args.get("custom_template")
templ_head = args.get("templ_head")
templ_body = args.get("templ_body")

nl = os.linesep
if format_ == ONE_TEXT:
name = title
Expand Down Expand Up @@ -122,7 +132,7 @@ def get_book_text(title, authors, highlights, format_,
text += get_csv_row(data) + "\n"
elif format_ == ONE_MD:
highs = []
if not custom_md:
if not custom_template:
text += f"\n---\n## {title} \n##### {authors} \n---\n"
for i in highlights:
comment = i[HI_COMMENT].replace(nl, " " + nl)
Expand All @@ -136,42 +146,43 @@ def get_book_text(title, authors, highlights, format_,
high + comment + " \n&nbsp; \n")
highs.append(h.replace("-", "\\-"))
else: # use custom markdown template
text += MD_HEAD.format(title, authors)
text += templ_head.format(title, authors)
for i in highlights:
comment = i[HI_COMMENT].replace(nl, " " + nl).replace("-", "\\-")
if comment:
comment = " " + comment
high = i[HI_TEXT].replace(nl, " " + nl).replace("-", "\\-")
date_ = i[HI_DATE].replace("-", "\\-")
highs.append(MD_HIGH.format(date_, comment, high,
i[HI_PAGE], i[HI_CHAPTER]))
highs.append(templ_body.format(date_, comment, high,
i[HI_PAGE], i[HI_CHAPTER]))
text += nl.join(highs) + "\n---\n"
return text


def save_file(title, authors, highlights, path, format_,
line_break, space, custom_md=False):
def save_file(args):
""" Saves the book's exported file
"""
ext = text = ""
encoding = "utf-8"
name = title
if authors:
name = f"{authors} - {title}"
if format_ == MANY_TEXT:
name = args["title"]
if args["authors"]:
name = f"{args['authors']} - {args['title']}"
if args["format_"] == MANY_TEXT:
ext = ".txt"
elif format_ == MANY_HTML:
elif args["format_"] == MANY_HTML:
ext = ".html"
text = HTML_HEAD
elif format_ == MANY_CSV:
elif args["format_"] == MANY_CSV:
ext = ".csv"
text = CSV_HEAD
encoding = "utf-8-sig"
elif format_ == MANY_MD:
elif args["format_"] == MANY_MD:
ext = ".md"
args["text"] = text
args["format_"] += 1

filename = join(path, sanitize_filename(name))
if NO_TITLE in title: # don't overwrite unknown title files
filename = join(args["dir_path"], sanitize_filename(name))
if NO_TITLE in args["title"]: # don't overwrite unknown title files
while isfile(filename + ext):
match = re.match(r"(.+?) \[(\d+?)]$", filename)
if match:
Expand All @@ -181,9 +192,8 @@ def save_file(title, authors, highlights, path, format_,
filename = filename + ext

with open(filename, "w+", encoding=encoding, newline="") as text_file:
text = get_book_text(title, authors, highlights, format_ + 1, line_break,
space, text, custom_md)
if format_ == MANY_HTML:
text = get_book_text(args)
if args["format_"] == MANY_HTML:
text += "\n</body>\n</html>"
text_file.write(text)

Expand Down

0 comments on commit 053c7fa

Please sign in to comment.