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

dfint / df-gettext-toolkit / 5870810915

pending completion
5870810915

push

github

insolor
Add refurb, fix its warnings

159 of 410 branches covered (38.78%)

Branch coverage included in aggregate %.

38 of 38 new or added lines in 14 files covered. (100.0%)

371 of 881 relevant lines covered (42.11%)

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 pathlib import Path
×
3
from typing import Iterable, Iterator, Sequence, TextIO
×
4

5
import typer
×
6

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

9

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

16

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

24

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

31

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

39

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