extra encoding support
This commit is contained in:
parent
f25acac6f1
commit
7e0ae5f49a
2 changed files with 8 additions and 3 deletions
|
@ -24,11 +24,16 @@ lang_from = sys.argv[1]
|
||||||
lang_to = sys.argv[2]
|
lang_to = sys.argv[2]
|
||||||
parallel = bool(distutils.util.strtobool(sys.argv[3]))
|
parallel = bool(distutils.util.strtobool(sys.argv[3]))
|
||||||
|
|
||||||
|
if (len(sys.argv) >= 5):
|
||||||
|
src_enc = sys.argv[4]
|
||||||
|
else:
|
||||||
|
src_enc = "utf-8"
|
||||||
|
|
||||||
if parallel:
|
if parallel:
|
||||||
import asyncio
|
import asyncio
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
sys.stdin.reconfigure(encoding='utf-8')
|
sys.stdin.reconfigure(encoding = src_enc)
|
||||||
rss_data = sys.stdin.read()
|
rss_data = sys.stdin.read()
|
||||||
rss_document = ET.fromstring(rss_data)
|
rss_document = ET.fromstring(rss_data)
|
||||||
translator = Translator()
|
translator = Translator()
|
||||||
|
@ -57,7 +62,7 @@ title.text = translate_string(title.text)
|
||||||
|
|
||||||
# Translate articles.
|
# Translate articles.
|
||||||
if parallel:
|
if parallel:
|
||||||
with ThreadPoolExecutor(max_workers = 8) as executor:
|
with ThreadPoolExecutor(max_workers = 2) as executor:
|
||||||
futures = []
|
futures = []
|
||||||
for article in rss_document.findall(".//item"):
|
for article in rss_document.findall(".//item"):
|
||||||
futures.append(executor.submit(process_article, article))
|
futures.append(executor.submit(process_article, article))
|
||||||
|
|
|
@ -562,7 +562,7 @@ QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QStrin
|
||||||
return raw_output;
|
return raw_output;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
process.kill();
|
//process.kill();
|
||||||
|
|
||||||
auto raw_error = process.readAllStandardError().simplified();
|
auto raw_error = process.readAllStandardError().simplified();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue