mirror of
https://github.com/nmap/nmap.git
synced 2026-02-05 21:16:33 +00:00
Replace == and != with is and is not for comparisons with None
This commit is contained in:
@@ -142,7 +142,7 @@ class NetworkInventory(object):
|
||||
# A dictionary mapping IP addresses into HostInfo objects
|
||||
self.hosts = {}
|
||||
|
||||
if filename != None:
|
||||
if filename is not None:
|
||||
self.open_from_file(filename)
|
||||
|
||||
def add_scan(self, scan, filename=None):
|
||||
@@ -177,7 +177,7 @@ class NetworkInventory(object):
|
||||
|
||||
self.scans.append(scan)
|
||||
|
||||
if filename != None:
|
||||
if filename is not None:
|
||||
basename = os.path.basename(filename)
|
||||
|
||||
if basename in self.filenames.values():
|
||||
|
||||
@@ -326,12 +326,12 @@ class NmapCommand(object):
|
||||
subprocess completed successfully. If the subprocess terminated with an
|
||||
error an exception is raised. The scan must have been started with
|
||||
run_scan before calling this method."""
|
||||
if self.command_process == None:
|
||||
if self.command_process is None:
|
||||
raise Exception("Scan is not running yet!")
|
||||
|
||||
state = self.command_process.poll()
|
||||
|
||||
if state == None:
|
||||
if state is None:
|
||||
return True # True means that the process is still running
|
||||
elif state == 0:
|
||||
return False # False means that the process had a successful exit
|
||||
|
||||
@@ -515,7 +515,7 @@ class NmapOptions(object):
|
||||
|
||||
def canonicalize_name(self, name):
|
||||
opt, arg, remainder = split_option(name, self.options)
|
||||
assert remainder == None
|
||||
assert remainder is None
|
||||
if arg is None:
|
||||
option = lookup_option(opt, self.options)
|
||||
if option:
|
||||
@@ -541,7 +541,7 @@ class NmapOptions(object):
|
||||
# A positional argument.
|
||||
self.target_specs.append(result)
|
||||
return
|
||||
elif result[0] == None:
|
||||
elif result[0] is None:
|
||||
# An unknown option.
|
||||
self.extras.extend(result[1:])
|
||||
return
|
||||
@@ -1170,10 +1170,10 @@ class NmapOptionsTest(unittest.TestCase):
|
||||
ops.parse_string("nmap -d#")
|
||||
self.assertTrue(ops.extras == ["-d#"])
|
||||
ops.parse_string("nmap -T monkeys")
|
||||
self.assertTrue(ops["-T"] == None)
|
||||
self.assertTrue(ops["-T"] is None)
|
||||
self.assertTrue(ops.extras == ["-T", "monkeys"])
|
||||
ops.parse_string("nmap -iR monkeys")
|
||||
self.assertTrue(ops["-iR"] == None)
|
||||
self.assertTrue(ops["-iR"] is None)
|
||||
self.assertTrue(ops.extras == ["-iR", "monkeys"])
|
||||
|
||||
def test_read_unknown(self):
|
||||
|
||||
@@ -518,7 +518,7 @@ class ParserBasics(object):
|
||||
self.nmap['scaninfo'] = info
|
||||
|
||||
def get_services_scanned(self):
|
||||
if self._services_scanned == None:
|
||||
if self._services_scanned is None:
|
||||
return self._services_scanned
|
||||
|
||||
services = []
|
||||
@@ -553,7 +553,7 @@ class ParserBasics(object):
|
||||
return protocols
|
||||
|
||||
def get_num_services(self):
|
||||
if self._num_services == None:
|
||||
if self._num_services is None:
|
||||
return self._num_services
|
||||
|
||||
num = 0
|
||||
|
||||
@@ -207,7 +207,7 @@ class HostSearch(object):
|
||||
@staticmethod
|
||||
def match_port(host_ports, port, port_state):
|
||||
# Check if the port is parsable, if not return False silently
|
||||
if re.match("^\d+$", port) == None:
|
||||
if re.match("^\d+$", port) is None:
|
||||
return False
|
||||
|
||||
for hp in host_ports:
|
||||
@@ -329,7 +329,7 @@ class SearchResult(object):
|
||||
fuzz = date_arg.count("~")
|
||||
date_arg = date_arg.replace("~", "")
|
||||
|
||||
if re.match("\d\d\d\d-\d\d-\d\d$", date_arg) != None:
|
||||
if re.match("\d\d\d\d-\d\d-\d\d$", date_arg) is not None:
|
||||
year, month, day = date_arg.split("-")
|
||||
parsed_date = date(int(year), int(month), int(day))
|
||||
elif re.match("[-|\+]\d+$", date_arg):
|
||||
@@ -392,7 +392,7 @@ class SearchResult(object):
|
||||
|
||||
# Check if they're parsable, if not return False silently
|
||||
for port in ports:
|
||||
if re.match("^\d+$", port) == None:
|
||||
if re.match("^\d+$", port) is None:
|
||||
return False
|
||||
|
||||
# Make a list of all scanned ports
|
||||
|
||||
@@ -464,7 +464,7 @@ class NmapOutputHighlight(object):
|
||||
return True
|
||||
|
||||
def set_enable(self, enable):
|
||||
if enable == False or enable == "0" or enable == None or enable == "":
|
||||
if enable == False or enable == "0" or enable is None or enable == "":
|
||||
config_parser.set(
|
||||
"output_highlight", "enable_highlight", str(False))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user