graviti.utility.common#

Common tools.

Module Contents#

Functions#

urlnorm(url)

Normalized the input url by removing the trailing slash.

locked(func)

The decorator to add threading lock for methods.

shorten(origin)

Return the first 7 characters of the original string.

Attributes#

graviti.utility.common.locks :DefaultDict[int, threading.Lock][source]#
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