idb_utils/tzo_odt.py
2025-05-17 04:28:55 +03:00

22 lines
811 B
Python
Executable File

#!/usr/bin/env python3
import os.path
from argparse import ArgumentParser
from idb import Article, DocumentCreator, tzo_urls, after_tzo_urls
from idb.util import name_from_url
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--after', action='store_true')
args = parser.parse_args()
urls = tzo_urls if not args.after else after_tzo_urls
for url in urls:
name = name_from_url(url)
orig = Article.from_markdown_file(os.path.join(os.path.dirname(__file__), 'tzo', f'{name}-ru.txt'), with_title=False)
trans = Article.from_markdown_file(os.path.join(os.path.dirname(__file__), 'tzo', f'{name}-en.txt'), with_title=False)
doc = DocumentCreator()
doc.create(orig, trans, os.path.join(os.path.dirname(__file__), f'{name}.odt'))