graviti.utility.common
#
Common tools.
Module Contents#
Classes#
The descriptor for the lazy loaded attr. |
|
The descriptor for the cached property. |
|
A fake module to raise |
Functions#
|
Normalized the input url by removing the trailing slash. |
|
The decorator to add threading lock for methods. |
|
Return the first 7 characters of the original string. |
|
Convert iso 8601 format string to datetime format time with local timezone. |
|
Convert datetime to gmt format string. |
Attributes#
- graviti.utility.common.urlnorm(url)[source]#
Normalized the input url by removing the trailing slash.
- Parameters
url (str) – the url needs to be normalized.
- Returns
The normalized url.
- Return type
str
- graviti.utility.common.locked(func)[source]#
The decorator to add threading lock for methods.
- Parameters
func (_CallableWithoutReturnValue) – The method needs to add threading lock.
- Returns
The method with theading locked.
- Return type
_CallableWithoutReturnValue
- graviti.utility.common.shorten(origin)[source]#
Return the first 7 characters of the original string.
- Parameters
origin (str) – The string needed to be shortened.
- Returns
A string of length 7.
- Return type
str
- graviti.utility.common.convert_iso_to_datetime(date_string)[source]#
Convert iso 8601 format string to datetime format time with local timezone.
- Parameters
date_string (str) – The iso 8601 format string.
- Returns
The datetime format time with local timezone.
- Return type
datetime.datetime
- graviti.utility.common.convert_datetime_to_gmt(utctime)[source]#
Convert datetime to gmt format string.
- Parameters
utctime (datetime.datetime) – The datetime with utc timezone.
- Returns
The gmt format string.
- Return type
str
- class graviti.utility.common.LazyAttr[source]#
Bases:
Generic
[_T
]The descriptor for the lazy loaded attr.