Cmp function backport and Utf8 to Byte response decorator helper funcations

This commit is contained in:
shortcutme 2019-03-15 23:55:23 +01:00
parent a49f454826
commit d4d86172f0
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -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