• 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_pot/from_raw_objects.py
1
from collections.abc import Iterable, Iterator
×
2
from pathlib import Path
×
3
from typing import BinaryIO
×
4

5
import typer
×
6

7
from df_gettext_toolkit.parse.parse_raws import extract_translatables_from_raws
×
8
from df_gettext_toolkit.utils.po_utils import TranslationItem, save_pot
×
9

10

11
def extract_from_raw_file(file_name: Path, source_encoding: str) -> Iterator[TranslationItem]:
×
12
    with file_name.open(encoding=source_encoding) as file:
×
13
        for item in extract_translatables_from_raws(file):
×
14
            item.source_file = file_name.name
×
15
            yield item
×
16

17

18
def extract_translatables_from_raws_batch(raw_files: Iterable[Path], source_encoding: str) -> Iterator[TranslationItem]:
×
19
    """
20
    Read all translatable items from all raw files
21
    """
22
    for file_name in raw_files:
×
23
        if file_name.is_file():
×
24
            yield from extract_from_raw_file(file_name, source_encoding)
×
25

26

27
def create_pot_file(pot_file: BinaryIO, raw_files: Iterable[Path], source_encoding: str):
×
28
    save_pot(
×
29
        pot_file,
30
        extract_translatables_from_raws_batch(raw_files, source_encoding),
31
    )
32

33

34
def main(raws_path: Path, pot_file: typer.FileBinaryWrite, source_encoding: str = "cp437"):
×
35
    raw_files = (file for file in raws_path.glob("*.txt") if not file.name.startswith("language_"))
×
36
    create_pot_file(pot_file, sorted(raw_files), source_encoding)
×
37

38

39
if __name__ == "__main__":
40
    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