mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
capitalization works only on char and number symbols
This commit is contained in:
parent
b912cd4ef0
commit
7ae3cf157e
1 changed files with 12 additions and 6 deletions
|
|
@ -97,6 +97,7 @@ def prepare_template_data(fill_pairs):
|
|||
|
||||
"""
|
||||
fill_data = {}
|
||||
regex = re.compile(r"[a-zA-Z0-9]")
|
||||
for key, value in dict(fill_pairs).items():
|
||||
# Handle cases when value is `None` (standalone publisher)
|
||||
if value is None:
|
||||
|
|
@ -108,13 +109,18 @@ def prepare_template_data(fill_pairs):
|
|||
|
||||
# Capitalize only first char of value
|
||||
# - conditions are because of possible index errors
|
||||
# - regex is to skip symbols that are not chars or numbers
|
||||
# - e.g. "{key}" which starts with curly bracket
|
||||
capitalized = ""
|
||||
if value:
|
||||
# Upper first character
|
||||
capitalized += value[0].upper()
|
||||
# Append rest of string if there is any
|
||||
if len(value) > 1:
|
||||
capitalized += value[1:]
|
||||
for idx in range(len(value or "")):
|
||||
char = value[idx]
|
||||
if not regex.match(char):
|
||||
capitalized += char
|
||||
else:
|
||||
capitalized += char.upper()
|
||||
capitalized += value[idx + 1:]
|
||||
break
|
||||
|
||||
fill_data[key.capitalize()] = capitalized
|
||||
|
||||
return fill_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue