mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
19 lines
429 B
Python
19 lines
429 B
Python
__all__ = (
|
|
'title',
|
|
'trailing_slash',
|
|
)
|
|
|
|
|
|
def title(value):
|
|
"""
|
|
Improved implementation of str.title(); retains all existing uppercase letters.
|
|
"""
|
|
return ' '.join([w[0].upper() + w[1:] for w in str(value).split()])
|
|
|
|
|
|
def trailing_slash(value):
|
|
"""
|
|
Remove a leading slash (if any) and include a trailing slash, except for empty strings.
|
|
"""
|
|
return f'{value.strip("/")}/' if value else ''
|