mirror of
https://github.com/sileht/bird-lg.git
synced 2024-11-26 08:44:43 +01:00
PEP8 compliance
This commit is contained in:
parent
8e55d6aac2
commit
c67f4644ae
|
@ -28,9 +28,11 @@ resolv = resolver.Resolver()
|
||||||
resolv.timeout = 0.5
|
resolv.timeout = 0.5
|
||||||
resolv.lifetime = 1
|
resolv.lifetime = 1
|
||||||
|
|
||||||
|
|
||||||
def resolve(n, q):
|
def resolve(n, q):
|
||||||
return str(resolv.query(n, q)[0])
|
return str(resolv.query(n, q)[0])
|
||||||
|
|
||||||
|
|
||||||
def mask_is_valid(n):
|
def mask_is_valid(n):
|
||||||
if not n:
|
if not n:
|
||||||
return True
|
return True
|
||||||
|
@ -40,6 +42,7 @@ def mask_is_valid(n):
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def ipv4_is_valid(n):
|
def ipv4_is_valid(n):
|
||||||
try:
|
try:
|
||||||
socket.inet_pton(socket.AF_INET, n)
|
socket.inet_pton(socket.AF_INET, n)
|
||||||
|
@ -47,6 +50,7 @@ def ipv4_is_valid(n):
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def ipv6_is_valid(n):
|
def ipv6_is_valid(n):
|
||||||
try:
|
try:
|
||||||
socket.inet_pton(socket.AF_INET6, n)
|
socket.inet_pton(socket.AF_INET6, n)
|
||||||
|
@ -54,11 +58,13 @@ def ipv6_is_valid(n):
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def save_cache_pickle(filename, data):
|
def save_cache_pickle(filename, data):
|
||||||
output = open(filename, 'wb')
|
output = open(filename, 'wb')
|
||||||
pickle.dump(data, output)
|
pickle.dump(data, output)
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
def load_cache_pickle(filename, default=None):
|
def load_cache_pickle(filename, default=None):
|
||||||
try:
|
try:
|
||||||
pkl_file = open(filename, 'rb')
|
pkl_file = open(filename, 'rb')
|
||||||
|
@ -71,6 +77,7 @@ def load_cache_pickle(filename, default = None):
|
||||||
pkl_file.close()
|
pkl_file.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def unescape(s):
|
def unescape(s):
|
||||||
want_unicode = False
|
want_unicode = False
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
|
|
Loading…
Reference in a new issue