• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dfint / df-gettext-toolkit / 5871136315

pending completion
5871136315

push

github

insolor
Upgrade style of the type annotations using ruff

157 of 404 branches covered (38.86%)

Branch coverage included in aggregate %.

53 of 53 new or added lines in 18 files covered. (100.0%)

369 of 876 relevant lines covered (42.12%)

1.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/df_gettext_toolkit/create_mod/batch.py
1
from pathlib import Path
×
2
from urllib.error import HTTPError
×
3

4
import requests
×
5
import typer
×
6
from loguru import logger
×
7

8
from df_gettext_toolkit.create_mod.from_template import main as from_template
×
9
from df_gettext_toolkit.create_mod.template_from_vanilla import main as template_from_vanilla
×
10

11
PO_URL = "https://raw.githubusercontent.com/dfint/translations-backup/main/translations/dwarf-fortress-steam"
×
12

13

14
def fetch_po_from_git(language: str, destination_path: Path) -> None:
×
15
    resources: list[str] = ["objects", "text_set"]
×
16
    for resource in resources:
×
17
        response = requests.get(f"{PO_URL}/{resource}/{language.lower()}.po")
×
18
        response.raise_for_status()
×
19
        file_path = Path(destination_path / f"{resource}_{language.lower()}.po")
×
20
        with file_path.open("w", encoding="utf-8") as file:
×
21
            file.write(response.text)
×
22
    logger.info(f"PO files for {language.upper()} downloaded")
×
23

24

25
@logger.catch
×
26
def main(vanilla_path: Path, destination_path: Path, encoding: str, languages: list[str]) -> None:
×
27
    assert vanilla_path.exists(), "Source path doesn't exist"
×
28
    assert destination_path.exists(), "Destination path doesn't exist"
×
29

30
    for language in languages:
×
31
        try:
×
32
            fetch_po_from_git(language, destination_path)
×
33
        except HTTPError as e:
×
34
            raise Exception(f"Unable to download po file for language {language}. Error: {e.code}, {e.reason}")
×
35
        Path.mkdir(destination_path / language.lower(), parents=True, exist_ok=True)
×
36
        template_from_vanilla(vanilla_path, destination_path / language.lower())
×
37
        from_template(destination_path / language.lower(), destination_path, language, encoding)
×
38

39
    for po in destination_path.glob("**/*.po"):
×
40
        po.unlink()
×
41

42
    logger.success("All done!")
×
43

44

45
if __name__ == "__main__":
46
    typer.run(main)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc