d
This commit is contained in:
24
Utilities/platform/2/generation/shortenName.py
Normal file
24
Utilities/platform/2/generation/shortenName.py
Normal file
@@ -0,0 +1,24 @@
|
||||
def shortenName(text):
|
||||
capitals = [l for l in text if l.isupper()]
|
||||
# Нет заглавных.
|
||||
if len(capitals) == 0:
|
||||
return text
|
||||
|
||||
capId = 0
|
||||
# Первая - заглавная.
|
||||
if text[0].isupper():
|
||||
capId = 1
|
||||
|
||||
# Заглавная лишь первая.
|
||||
if (
|
||||
capId == 1 and
|
||||
len(capitals) == 1
|
||||
):
|
||||
return text
|
||||
|
||||
# Убираем первое заглавное слово.
|
||||
if capId == 1:
|
||||
capitals = capitals[1:]
|
||||
# Есть ещё заглавные.
|
||||
firstCap = text.find(capitals[0])
|
||||
return text[:firstCap] + "".join(capitals)
|
||||
Reference in New Issue
Block a user