Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/python_slugify-8.0.4-py3.11.egg/slugify/special.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

15 statements  

1from __future__ import annotations 

2 

3 

4def add_uppercase_char(char_list: list[tuple[str, str]]) -> list[tuple[str, str]]: 

5 """ Given a replacement char list, this adds uppercase chars to the list """ 

6 

7 for item in char_list: 

8 char, xlate = item 

9 upper_dict = char.upper(), xlate.capitalize() 

10 if upper_dict not in char_list and char != upper_dict[0]: 

11 char_list.insert(0, upper_dict) 

12 return char_list 

13 

14 

15# Language specific pre translations 

16# Source awesome-slugify 

17 

18_CYRILLIC = [ # package defaults: 

19 (u'ё', u'e'), # io / yo 

20 (u'я', u'ya'), # ia 

21 (u'х', u'h'), # kh 

22 (u'у', u'y'), # u 

23 (u'щ', u'sch'), # sch 

24 (u'ю', u'u'), # iu / yu 

25] 

26CYRILLIC = add_uppercase_char(_CYRILLIC) 

27 

28_GERMAN = [ # package defaults: 

29 (u'ä', u'ae'), # a 

30 (u'ö', u'oe'), # o 

31 (u'ü', u'ue'), # u 

32] 

33GERMAN = add_uppercase_char(_GERMAN) 

34 

35_GREEK = [ # package defaults: 

36 (u'χ', u'ch'), # kh 

37 (u'Ξ', u'X'), # Ks 

38 (u'ϒ', u'Y'), # U 

39 (u'υ', u'y'), # u 

40 (u'ύ', u'y'), 

41 (u'ϋ', u'y'), 

42 (u'ΰ', u'y'), 

43] 

44GREEK = add_uppercase_char(_GREEK) 

45 

46# Pre translations 

47PRE_TRANSLATIONS = CYRILLIC + GERMAN + GREEK