• 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_speech.py
1
import sys
×
2
from collections.abc import Iterable, Iterator, Sequence
×
3
from pathlib import Path
×
4
from typing import TextIO
×
5

6
import typer
×
7

8
from df_gettext_toolkit.utils.po_utils import TranslationItem, save_pot
×
9

10

11
def extract_from_speech_file(file: TextIO, source_path: str):
×
12
    for i, line in enumerate(file, 1):
×
13
        text = line.rstrip("\n")
×
14
        if text:
×
15
            yield TranslationItem(text=text, source_file=source_path, line_number=i)
×
16

17

18
def extract_translatables(files: Iterable[Path]) -> Iterator[TranslationItem]:
×
19
    for file_path in files:
×
20
        if file_path.is_file():
×
21
            print("File:", file_path.name, file=sys.stderr)
×
22
            with file_path.open() as file:
×
23
                yield from extract_from_speech_file(file, file_path.name)
×
24

25

26
def create_pot_file(pot_file: typer.FileBinaryWrite, files: Sequence[Path]):
×
27
    save_pot(
×
28
        pot_file,
29
        extract_translatables(files),
30
    )
31

32

33
def main(
×
34
    path: Path,
35
    pot_file: typer.FileBinaryWrite,
36
):
37
    files = (file for file in path.glob("*.txt") if file.is_file())
×
38
    create_pot_file(pot_file, sorted(files))
×
39

40

41
if __name__ == "__main__":
42
    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