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.lifetime = 1
|
||||
|
||||
|
||||
def resolve(n, q):
|
||||
return str(resolv.query(n, q)[0])
|
||||
|
||||
|
||||
def mask_is_valid(n):
|
||||
if not n:
|
||||
return True
|
||||
|
@ -40,6 +42,7 @@ def mask_is_valid(n):
|
|||
except:
|
||||
return False
|
||||
|
||||
|
||||
def ipv4_is_valid(n):
|
||||
try:
|
||||
socket.inet_pton(socket.AF_INET, n)
|
||||
|
@ -47,6 +50,7 @@ def ipv4_is_valid(n):
|
|||
except socket.error:
|
||||
return False
|
||||
|
||||
|
||||
def ipv6_is_valid(n):
|
||||
try:
|
||||
socket.inet_pton(socket.AF_INET6, n)
|
||||
|
@ -54,11 +58,13 @@ def ipv6_is_valid(n):
|
|||
except socket.error:
|
||||
return False
|
||||
|
||||
|
||||
def save_cache_pickle(filename, data):
|
||||
output = open(filename, 'wb')
|
||||
pickle.dump(data, output)
|
||||
output.close()
|
||||
|
||||
|
||||
def load_cache_pickle(filename, default=None):
|
||||
try:
|
||||
pkl_file = open(filename, 'rb')
|
||||
|
@ -71,6 +77,7 @@ def load_cache_pickle(filename, default = None):
|
|||
pkl_file.close()
|
||||
return data
|
||||
|
||||
|
||||
def unescape(s):
|
||||
want_unicode = False
|
||||
if isinstance(s, unicode):
|
||||
|
|
Loading…
Reference in a new issue