Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Chained Comparison Simplification

Gormogon6b8567a7de40
diff --git a/ext/dns/inet.py b/ext/dns/inet.py
index 3b7e88f7..be1b970e 100644
--- a/ext/dns/inet.py
+++ b/ext/dns/inet.py
@@ -98,7 +98,7 @@ def is_multicast(text):
"""
try:
first = ord(dns.ipv4.inet_aton(text)[0])
- return (first >= 224 and first <= 239)
+ return (224 <= first <= 239)
except:
try:
first = ord(dns.ipv6.inet_aton(text)[0])
diff --git a/ext/dns/name.py b/ext/dns/name.py
index 293ab951..19529fef 100644
--- a/ext/dns/name.py
+++ b/ext/dns/name.py
@@ -95,7 +95,7 @@ def _escapify(label):
for c in label:
if c in _escaped:
text += '\\' + c
- elif ord(c) > 0x20 and ord(c) < 0x7F:
+ elif 0x20 < ord(c) < 0x7F:
text += c
else:
text += '\\%03d' % ord(c)
diff --git a/ext/dns/opcode.py b/ext/dns/opcode.py
index 3258c34c..5c88e706 100644
--- a/ext/dns/opcode.py
+++ b/ext/dns/opcode.py
@@ -53,7 +53,7 @@ def from_text(text):
if text.isdigit():
value = int(text)
- if value >= 0 and value <= 15:
+ if 0 <= value <= 15:
return value
value = _by_text.get(text.upper())
if value is None:
diff --git a/ext/dns/rcode.py b/ext/dns/rcode.py
index 7807782a..a1790f4d 100644
--- a/ext/dns/rcode.py
+++ b/ext/dns/rcode.py
@@ -67,7 +67,7 @@ def from_text(text):
if text.isdigit():
v = int(text)
- if v >= 0 and v <= 4095:
+ if 0 <= v <= 4095:
return v
v = _by_text.get(text.upper())
if v is None:
diff --git a/ext/dns/rdata.py b/ext/dns/rdata.py
index 350bf790..162ba151 100644
--- a/ext/dns/rdata.py
+++ b/ext/dns/rdata.py
@@ -104,7 +104,7 @@ def _escapify(qstring):
for c in qstring:
if c in __escaped:
text += '\\' + c
- elif ord(c) >= 0x20 and ord(c) < 0x7F:
+ elif 0x20 <= ord(c) < 0x7F:
text += c
else:
text += '\\%03d' % ord(c)
diff --git a/ext/dns/rdatatype.py b/ext/dns/rdatatype.py
index fe7cbff3..ff81a054 100644
--- a/ext/dns/rdatatype.py
+++ b/ext/dns/rdatatype.py
@@ -219,7 +219,7 @@ def is_metatype(rdtype):
@type rdtype: int
@rtype: bool"""
- if rdtype >= TKEY and rdtype <= ANY or _metatypes.has_key(rdtype):
+ if TKEY <= rdtype <= ANY or _metatypes.has_key(rdtype):
return True
return False
diff --git a/ext/exifread/utils.py b/ext/exifread/utils.py
index f5e0d7fe..ed4c8daf 100644
--- a/ext/exifread/utils.py
+++ b/ext/exifread/utils.py
@@ -17,7 +17,7 @@ def make_string(seq):
for c in seq:
# Screen out non-printing characters
try:
- if 32 <= c and c < 256:
+ if 32 <= c < 256:
string += chr(c)
except TypeError:
pass
diff --git a/ext/pyPdf/filters.py b/ext/pyPdf/filters.py
index 7fe10fb4..ebdacd0e 100644
--- a/ext/pyPdf/filters.py
+++ b/ext/pyPdf/filters.py
@@ -106,7 +106,7 @@ class FlateDecode(object):
if predictor != 1:
columns = decodeParms["/Columns"]
# PNG prediction:
- if predictor >= 10 and predictor <= 15:
+ if 10 <= predictor <= 15:
output = StringIO()
# PNG prediction can vary from row to row
rowlength = columns + 1
@@ -191,7 +191,7 @@ class ASCII85Decode(object):
break
else:
c = ord(c) - 33
- assert c >= 0 and c < 85
+ assert 0 <= c < 85
group += [ c ]
if len(group) >= 5:
b = group[0] * (85**4) + \