(copy_file_file): reduce variable scope, change order of progress update.
[midnight-commander.git] / maint / sync-transifex / hints-from-transifex.py
blobeefc6d3bddd1779919b81b109dabc6dd2b5aff1a
1 #!/usr/bin/env python3
3 import glob
4 import subprocess
5 from pathlib import Path
6 from textwrap import wrap
8 from translation_utils import create_po4a_config, init_sync_dir
10 RESOURCE_NAME = "mc.hint"
12 SCRIPT_DIR = Path(__file__).parent
13 SOURCE_DIR = SCRIPT_DIR.parent.parent
16 def unwrap_paragraphs():
17 hint_files = glob.glob(str(SOURCE_DIR / "doc" / "hints" / "l10n" / "mc.hint.*"))
18 for hint_file in map(Path, hint_files):
19 lines = hint_file.read_text().split("\n\n")
20 hint_file.write_text("\n\n".join("".join(wrap(line, width=1024)) for line in lines) + "\n")
23 sync_dir = init_sync_dir(SCRIPT_DIR, RESOURCE_NAME)
25 subprocess.run(("tx", "pull", "--all", "--force"), cwd=sync_dir, check=True)
27 po4a_config = create_po4a_config(sync_dir, SCRIPT_DIR, SOURCE_DIR, RESOURCE_NAME)
29 subprocess.run(("po4a", str(po4a_config)), cwd=SCRIPT_DIR, check=True)
31 unwrap_paragraphs()