Skip to content

Commit

Permalink
2.2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
noembryo committed Oct 5, 2024
1 parent 053c7fa commit 9e8b58a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


__author__ = "noEmbryo"
__version__ = "2.2.1.0"
__version__ = "2.2.1.1"


class Base(QMainWindow, Ui_Base):
Expand Down
22 changes: 12 additions & 10 deletions secondary.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,26 @@ def save_file(args):
"""
ext = text = ""
encoding = "utf-8"
name = args["title"]
if args["authors"]:
name = f"{args['authors']} - {args['title']}"
if args["format_"] == MANY_TEXT:
title = name = args["title"]
authors = args["authors"]
format_ = args["format_"]
if authors:
name = f"{authors} - {name}"
if format_ == MANY_TEXT:
ext = ".txt"
elif args["format_"] == MANY_HTML:
elif format_ == MANY_HTML:
ext = ".html"
text = HTML_HEAD
elif args["format_"] == MANY_CSV:
elif format_ == MANY_CSV:
ext = ".csv"
text = CSV_HEAD
encoding = "utf-8-sig"
elif args["format_"] == MANY_MD:
elif format_ == MANY_MD:
ext = ".md"
args["text"] = text
args["format_"] += 1

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

with open(filename, "w+", encoding=encoding, newline="") as text_file:
args["format_"] += 1 # the format is changed to the MERGED file, to get the text
text = get_book_text(args)
if args["format_"] == MANY_HTML:
if format_ == MANY_HTML:
text += "\n</body>\n</html>"
text_file.write(text)

Expand Down

0 comments on commit 9e8b58a

Please sign in to comment.