-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
__main__.py
37 lines (32 loc) · 932 Bytes
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Create X-Ray file on macOS: run this script in subprocess to bypass
the ludicrous library validation
"""
import argparse
import json
import sys
from pathlib import Path
from dump_lemmas import dump_spacy_docs
from parse_job import ParseJobData, create_files
parser = argparse.ArgumentParser()
parser.add_argument("job_data")
parser.add_argument("prefs")
args = parser.parse_args()
job_data = json.loads(args.job_data)
prefs = json.loads(args.prefs)
if "db_path" in job_data:
dump_spacy_docs(
job_data["model_name"],
job_data["is_kindle"],
job_data["lemma_lang"],
Path(job_data["db_path"]),
Path(job_data["plugin_path"]),
prefs,
)
else:
data = ParseJobData(**job_data)
if data.book_fmt == "KFX":
data.kfx_json = json.load(sys.stdin)
elif data.book_fmt != "EPUB":
data.mobi_html = sys.stdin.buffer.read()
create_files(data, prefs, None)