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

dfint / df-gettext-toolkit / 5912512907

19 Aug 2023 04:49PM UTC coverage: 44.838% (+1.1%) from 43.719%
5912512907

push

github

insolor
Move validation into a separate module

170 of 408 branches covered (41.67%)

Branch coverage included in aggregate %.

32 of 32 new or added lines in 4 files covered. (100.0%)

425 of 919 relevant lines covered (46.25%)

1.52 hits per line

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

14.29
/df_gettext_toolkit/validation/validate_objects.py
1
from df_gettext_toolkit.parse.parse_raws import all_caps, split_tag
3✔
2

3

4
def validate_brackets(tag: str):
3✔
5
    return tag.startswith("[") and tag.endswith("]") and tag.count("[") == 1 and tag.count("]") == 1
×
6

7

8
def validate_tag(original_tag: str, translation_tag: str):
3✔
9
    assert len(translation_tag) > 2, "Too short or empty translation"
×
10
    assert translation_tag.strip() == translation_tag, "Extra spaces at the beginning or at the end of the translation"
×
11
    assert validate_brackets(translation_tag), "Wrong tag translation format"
×
12

13
    original_parts = split_tag(original_tag)
×
14
    translation_parts = split_tag(translation_tag)
×
15
    assert len(original_parts) == len(translation_parts), "Tag parts count mismatch"
×
16
    validate_tag_parts(original_parts, translation_parts)
×
17

18

19
def validate_tag_parts(original_parts: list[str], translation_parts: list[str]):
3✔
20
    for original, translation in zip(original_parts, translation_parts):
×
21
        if all_caps(original) or original.isdecimal():
×
22
            valid = original == translation or original in ("STP", "NP", "SINGULAR", "PLURAL")
×
23
            assert valid, f"Part {original!r} should not be translated"
×
24

25
            if original == "STP":
×
26
                assert translation != "STP", (
×
27
                    "Replace STP with a translation of the previous word in the tag in a plural form, "
28
                    "otherwise, the game will create a plural form with adding -s at the end. "
29
                    "If the translation with adding -s at the end is valid for your language, just ignore this message."
30
                )
31
        elif original:
×
32
            assert translation, "Translation should not be empty"
×
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

© 2025 Coveralls, Inc