-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add text beatification (add final dot, capitalization)
- Loading branch information
1 parent
00d148d
commit 993f49a
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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', | ||
'unslugify', | ||
) | ||
|
||
|
||
def unslugify(value: AnyStr) -> AnyStr: | ||
return value.replace('-', ' ').title() if value else '' | ||
|
||
|
||
def capitalize(value: AnyStr) -> AnyStr: | ||
if len(value) == 0: | ||
return value | ||
return '. '.join([val.strip().capitalize() for val in value.split('.')]).strip() | ||
|
||
|
||
def add_final_dot(value: AnyStr) -> AnyStr: | ||
if len(value) and value[-1].isalnum(): | ||
return value + "." | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters