text
stringlengths 1
93.6k
|
|---|
if data.create_ww and data.book_fmt != "EPUB" and data.book_lang != "en"
|
else False
|
)
|
if set_en_lang:
|
en_book_path = Path(data.book_path)
|
en_book_path = en_book_path.with_stem(en_book_path.stem + "_en")
|
if not en_book_path.exists():
|
shutil.copy(data.book_path, en_book_path)
|
data.book_path = str(en_book_path)
|
get_asin_etc(data, set_en_lang=set_en_lang)
|
data.plugin_path = get_plugin_path()
|
data.useragent = get_user_agent()
|
data.spacy_model = spacy_model_name(data.book_lang, prefs)
|
if data.book_fmt == "EPUB":
|
new_epub_path = Path(data.book_path)
|
new_file_stem = new_epub_path.stem
|
if data.create_x:
|
new_file_stem += "_x_ray"
|
if data.create_ww:
|
new_file_stem += "_word_wise"
|
new_epub_path = new_epub_path.with_stem(new_file_stem)
|
data.create_x = data.create_x and not new_epub_path.exists()
|
data.create_ww = data.create_ww and not new_epub_path.exists()
|
shutil.copy(data.book_path, new_epub_path)
|
data.book_path = str(new_epub_path)
|
if (
|
data.create_ww
|
and not wiktionary_db_path(
|
data.plugin_path, data.book_lang, prefs["gloss_lang"]
|
).exists()
|
):
|
download_word_wise_file(
|
False, data.book_lang, prefs, notifications=notifications
|
)
|
else:
|
data.create_ww = (
|
data.create_ww and not get_ll_path(data.asin, data.book_path).exists()
|
)
|
data.create_x = (
|
data.create_x and not get_x_ray_path(data.asin, data.book_path).exists()
|
)
|
if data.create_ww and (
|
not kindle_db_path(data.plugin_path, data.book_lang, prefs).exists()
|
or not get_wiktionary_klld_path(
|
data.plugin_path, data.book_lang, prefs["gloss_lang"]
|
).exists()
|
):
|
download_word_wise_file(
|
True, data.book_lang, prefs, notifications=notifications
|
)
|
if not data.create_ww and not data.create_x:
|
return data
|
if isfrozen and (data.book_fmt == "EPUB" or data.create_x):
|
# parse MediaWiki page and Wikipedia section requires lxml
|
install_deps("lxml", notifications)
|
install_deps(data.spacy_model, notifications)
|
if notifications:
|
notifications.put((0, "Creating files"))
|
# Run plugin code in another Python process
|
# macOS: bypass library validation
|
# official calibre build: calibre's optimize level is 2 which removes docstring,
|
# but the "transformers" package formats docstrings in their code
|
# and calibre-debug can't be used as Python interpreter for pip
|
if isfrozen:
|
py_path, _ = which_python()
|
# copy data can't be converted by `asdict`
|
copy_mi = data.mi
|
copy_mobi_html = data.mobi_html # bytes
|
copy_kfx_json = data.kfx_json # too long
|
data.mi = None
|
data.mobi_html = None
|
data.kfx_json = None
|
data.plugin_path = str(data.plugin_path)
|
args = [
|
py_path,
|
"-I", # isolate user env
|
str(data.plugin_path),
|
json.dumps(asdict(data)),
|
dump_prefs(prefs),
|
]
|
data.mi = copy_mi
|
input_str = None
|
if data.book_fmt == "KFX":
|
input_str = json.dumps(copy_kfx_json).encode("utf-8")
|
elif data.book_fmt != "EPUB":
|
input_str = copy_mobi_html
|
run_subprocess(args, input_str)
|
else:
|
create_files(data, prefs, notifications)
|
return data
|
def calculate_final_start(data: ParseJobData) -> int:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.