Commit 4ac8790e authored by Petr Špaček's avatar Petr Špaček

Deckard: PEP8 boolean expression fixes

Trivial changes to pythonify boolean expressions and avoid pep8 error E712
"comparison to True should ..."
parent d6deddd1
...@@ -31,7 +31,7 @@ def del_files(path_to, delpath): ...@@ -31,7 +31,7 @@ def del_files(path_to, delpath):
for root, dirs, files in os.walk(path_to): for root, dirs, files in os.walk(path_to):
for f in files: for f in files:
os.unlink(os.path.join(root, f)) os.unlink(os.path.join(root, f))
if delpath == True: if delpath:
try: try:
os.rmdir(path_to) os.rmdir(path_to)
except: except:
...@@ -241,7 +241,7 @@ def play_object(path, binary_name, config_name, j2template, binary_additional_pa ...@@ -241,7 +241,7 @@ def play_object(path, binary_name, config_name, j2template, binary_additional_pa
sock = socket.socket(sockfamily, socket.SOCK_STREAM) sock = socket.socket(sockfamily, socket.SOCK_STREAM)
while True: while True:
time.sleep(0.1) time.sleep(0.1)
if daemon_proc.poll() != None: if daemon_proc.poll():
server.stop() server.stop()
print(open('%s/server.log' % TMPDIR).read()) print(open('%s/server.log' % TMPDIR).read())
raise Exception('process died "%s", logs in "%s"' % raise Exception('process died "%s", logs in "%s"' %
......
...@@ -209,7 +209,7 @@ class Entry: ...@@ -209,7 +209,7 @@ class Entry:
# Find matching NSID # Find matching NSID
for opt in msg.options: for opt in msg.options:
if opt.otype == dns.edns.NSID: if opt.otype == dns.edns.NSID:
if nsid_opt == None: if not nsid_opt:
raise Exception('unexpected NSID value "%s"' % opt.data) raise Exception('unexpected NSID value "%s"' % opt.data)
if opt == nsid_opt: if opt == nsid_opt:
return True return True
...@@ -312,7 +312,7 @@ class Entry: ...@@ -312,7 +312,7 @@ class Entry:
for v in fields: for v in fields:
k, v = tuple(v.split('=')) if '=' in v else (v, True) k, v = tuple(v.split('=')) if '=' in v else (v, True)
if k.lower() == 'nsid': if k.lower() == 'nsid':
opts.append(dns.edns.GenericOption(dns.edns.NSID, '' if v == True else v)) opts.append(dns.edns.GenericOption(dns.edns.NSID, '' if v is True else v))
if k.lower() == 'subnet': if k.lower() == 'subnet':
net = v.split('/') net = v.split('/')
family = socket.AF_INET6 if ':' in net[0] else socket.AF_INET family = socket.AF_INET6 if ':' in net[0] else socket.AF_INET
...@@ -340,7 +340,7 @@ class Entry: ...@@ -340,7 +340,7 @@ class Entry:
def add_record(self, owner, args): def add_record(self, owner, args):
""" Add record to current packet section. """ """ Add record to current packet section. """
if self.raw_data_pending is True: if self.raw_data_pending is True:
if self.raw_data == None: if self.raw_data is None:
if owner == 'NULL': if owner == 'NULL':
self.raw_data = None self.raw_data = None
else: else:
...@@ -405,7 +405,7 @@ class Range: ...@@ -405,7 +405,7 @@ class Range:
def eligible(self, id, address): def eligible(self, id, address):
""" Return true if this range is eligible for fetching reply. """ """ Return true if this range is eligible for fetching reply. """
if self.a <= id <= self.b: if self.a <= id <= self.b:
return (None == address return (None is address
or set() == self.addresses or set() == self.addresses
or address in self.addresses) or address in self.addresses)
return False return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment