Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/auto_correct.py: 100%

# Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/auto_correct.py : 100%

## 19 statements 19 run 0 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from typing import AnyStr __author__ = 'Artur Barseghyan' __copyright__ = '2019 Artur Barseghyan' __license__ = 'GPL-2.0-only OR LGPL-2.0-or-later' __all__ = ( 'add_final_dot', 'capitalize', 'capitalize_first_letter', 'unslugify', ) def capitalize_first_letter(value: AnyStr) -> AnyStr: if len(value) == 0: return value return value[0].upper() + value[1:] def unslugify(value: AnyStr) -> AnyStr: return capitalize_first_letter(value.replace('-', ' ')) if value else '' def capitalize(value: AnyStr) -> AnyStr: if len(value) == 0: return value return '. '.join( [capitalize_first_letter(val.strip()) for val in value.split('.')] ).strip() def add_final_dot(value: AnyStr) -> AnyStr: if len(value) and value[-1].isalnum() and not value.endswith('.'): return value + "." return value