Cmp function backport and Utf8 to Byte response decorator helper funcations
This commit is contained in:
parent
a49f454826
commit
d4d86172f0
1 changed files with 16 additions and 0 deletions
|
@ -289,3 +289,19 @@ def getInterfaceIps(ip_type="ipv4"):
|
||||||
|
|
||||||
res = [re.sub("%.*", "", ip) for ip in res if getIpType(ip) == ip_type and isIp(ip)]
|
res = [re.sub("%.*", "", ip) for ip in res if getIpType(ip) == ip_type and isIp(ip)]
|
||||||
return list(set(res))
|
return list(set(res))
|
||||||
|
|
||||||
|
|
||||||
|
def cmp(a, b):
|
||||||
|
return (a > b) - (a < b)
|
||||||
|
|
||||||
|
|
||||||
|
def encodeResponse(func):
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
back = func(*args, **kwargs)
|
||||||
|
if "__next__" in dir(back):
|
||||||
|
for part in back:
|
||||||
|
yield part.encode()
|
||||||
|
else:
|
||||||
|
yield back.encode()
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
Loading…
Reference in a new issue