mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
fix: bugs for using exlude_filelists and only_filelists (#324)
* fix: bugs for using exlude_filelists and only_filelists 1. progress bars: only calculating tags in files that will be included 2. temp_file: avoid mismatch between translated texts and original texts * simplify logic
This commit is contained in:
parent
b4817f2c9b
commit
358f6a8616
@ -403,13 +403,27 @@ class EPUBBookLoader(BaseBookLoader):
|
||||
trans_taglist = self.translate_tags.split(",")
|
||||
all_p_length = sum(
|
||||
0
|
||||
if i.get_type() != ITEM_DOCUMENT
|
||||
if (
|
||||
(i.get_type() != ITEM_DOCUMENT)
|
||||
or (i.file_name in self.exclude_filelist.split(","))
|
||||
or (
|
||||
self.only_filelist
|
||||
and i.file_name not in self.only_filelist.split(",")
|
||||
)
|
||||
)
|
||||
else len(bs(i.content, "html.parser").findAll(trans_taglist))
|
||||
for i in all_items
|
||||
)
|
||||
all_p_length += self.allow_navigable_strings * sum(
|
||||
0
|
||||
if i.get_type() != ITEM_DOCUMENT
|
||||
if (
|
||||
(i.get_type() != ITEM_DOCUMENT)
|
||||
or (i.file_name in self.exclude_filelist.split(","))
|
||||
or (
|
||||
self.only_filelist
|
||||
and i.file_name not in self.only_filelist.split(",")
|
||||
)
|
||||
)
|
||||
else len(bs(i.content, "html.parser").findAll(text=True))
|
||||
for i in all_items
|
||||
)
|
||||
@ -464,7 +478,14 @@ class EPUBBookLoader(BaseBookLoader):
|
||||
index = 0
|
||||
try:
|
||||
for item in origin_book_temp.get_items():
|
||||
if item.get_type() == ITEM_DOCUMENT:
|
||||
if (
|
||||
item.get_type() == ITEM_DOCUMENT
|
||||
and (item.file_name not in self.exclude_filelist.split(","))
|
||||
and (
|
||||
item.file_name in self.only_filelist.split(",")
|
||||
or self.only_filelist != ""
|
||||
)
|
||||
):
|
||||
soup = bs(item.content, "html.parser")
|
||||
p_list = soup.findAll(trans_taglist)
|
||||
if self.allow_navigable_strings:
|
||||
|
Loading…
x
Reference in New Issue
Block a user