diff --git a/zenmap/radialnet/bestwidgets/comboboxes.py b/zenmap/radialnet/bestwidgets/comboboxes.py index 23d3d1fbe..f82cd1b54 100644 --- a/zenmap/radialnet/bestwidgets/comboboxes.py +++ b/zenmap/radialnet/bestwidgets/comboboxes.py @@ -153,7 +153,7 @@ class BWChangeableComboBoxEntry(gtk.ComboBoxEntry): """ """ if len(self.__liststore) > 0 and\ - self.__last_active != None and\ + self.__last_active is not None and\ self.get_active() == -1: iter = self.get_model().get_iter((self.__last_active,)) diff --git a/zenmap/radialnet/core/Graph.py b/zenmap/radialnet/core/Graph.py index 8219cb0ae..0936af164 100644 --- a/zenmap/radialnet/core/Graph.py +++ b/zenmap/radialnet/core/Graph.py @@ -263,7 +263,7 @@ class Graph: b.add_edge(edge) # then add new weight value - if weight != None: + if weight is not None: edge.add_weight(weight) diff --git a/zenmap/radialnet/core/XMLHandler.py b/zenmap/radialnet/core/XMLHandler.py index f05374ba6..0423986c0 100644 --- a/zenmap/radialnet/core/XMLHandler.py +++ b/zenmap/radialnet/core/XMLHandler.py @@ -211,7 +211,7 @@ class XMLNode: c_result = child.query_children(name, attr, value, first, deep) - if c_result != None: + if c_result is not None: if first: return c_result @@ -245,7 +245,7 @@ class XMLNode: c_result = child.search_children(name, first, deep) - if c_result != None and c_result != []: + if c_result is not None and c_result != []: if first: return c_result @@ -329,7 +329,7 @@ class XMLReader(xml.sax.ContentHandler): def parse(self): """ """ - if self.__file != None: + if self.__file is not None: self.__parser.parse(self.__file) def startDocument(self): @@ -351,7 +351,7 @@ class XMLReader(xml.sax.ContentHandler): if len(self.__status) > 0: self.__status[-1].add_child(node) - if self.__root == None: + if self.__root is None: self.__root = node self.__status.append(node) diff --git a/zenmap/radialnet/gui/ControlWidget.py b/zenmap/radialnet/gui/ControlWidget.py index 083ffd8e6..7291fb7ba 100644 --- a/zenmap/radialnet/gui/ControlWidget.py +++ b/zenmap/radialnet/gui/ControlWidget.py @@ -1091,7 +1091,7 @@ class ControlNavigation(gtk.DrawingArea): direction = self.__move_is_clicked(pointer) - if direction != None and self.__moving == None: + if direction is not None and self.__moving is None: event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) self.__moving = direction @@ -1285,7 +1285,7 @@ class ControlNavigation(gtk.DrawingArea): def __move_in_direction(self, direction): """ """ - if self.__moving != None: + if self.__moving is not None: bx, by = self.__move_position ax, ay = self.__move_addition[direction] diff --git a/zenmap/radialnet/gui/HostsViewer.py b/zenmap/radialnet/gui/HostsViewer.py index ac573c4b2..2b2a5d2cc 100644 --- a/zenmap/radialnet/gui/HostsViewer.py +++ b/zenmap/radialnet/gui/HostsViewer.py @@ -171,7 +171,7 @@ class HostsViewer(BWMainWindow): def change_notebook(self, node): """ """ - if self.__view != None: + if self.__view is not None: self.__view.destroy() if node is not None: diff --git a/zenmap/radialnet/gui/Image.py b/zenmap/radialnet/gui/Image.py index 5876d957b..1c9b31fa8 100644 --- a/zenmap/radialnet/gui/Image.py +++ b/zenmap/radialnet/gui/Image.py @@ -178,7 +178,7 @@ class Image: def get_pixbuf(self, icon, image_type='png'): """ """ - if self.__path == None: + if self.__path is None: return False if icon + image_type not in self.__cache.keys(): @@ -192,7 +192,7 @@ class Image: def get_icon(self, icon, image_type='png'): """ """ - if self.__path == None: + if self.__path is None: return False return os.path.join(self.__path, icon + "." + image_type) diff --git a/zenmap/radialnet/gui/NodeNotebook.py b/zenmap/radialnet/gui/NodeNotebook.py index c8c323297..da1272950 100644 --- a/zenmap/radialnet/gui/NodeNotebook.py +++ b/zenmap/radialnet/gui/NodeNotebook.py @@ -446,7 +446,7 @@ class SystemPage(BWScrolledWindow): params = address['type'], address['addr'] address_text = SYSTEM_ADDRESS_TEXT % params - if address['vendor'] != None and address['vendor'] != '': + if address['vendor'] is not None and address['vendor'] != '': address_text += " (%s)" % address['vendor'] self.__address_list.append_text(address_text) @@ -458,7 +458,7 @@ class SystemPage(BWScrolledWindow): xoptions=gtk.FILL) self.__general.bw_attach_next(self.__address_list, yoptions=gtk.FILL) - if self.__node.get_info('hostnames') != None: + if self.__node.get_info('hostnames') is not None: self.__hostname_label = BWSectionLabel(_('Hostname:')) self.__hostname_list = gtk.combo_box_entry_new_text() @@ -477,7 +477,7 @@ class SystemPage(BWScrolledWindow): self.__general.bw_attach_next(self.__hostname_list, yoptions=gtk.FILL) - if self.__node.get_info('uptime') != None: + if self.__node.get_info('uptime') is not None: self.__uptime_label = BWSectionLabel(_('Last boot:')) @@ -509,7 +509,7 @@ class SystemPage(BWScrolledWindow): os = self.__node.get_info('os') - if os != None: + if os is not None: if 'matches' in os: @@ -703,7 +703,7 @@ class SystemPage(BWScrolledWindow): table.attach(tcp_ts_class, 1, 2, 3, 4) - if tcp_ts['values'] != None: + if tcp_ts['values'] is not None: tcp_ts_values = gtk.combo_box_entry_new_text() diff --git a/zenmap/radialnet/gui/RadialNet.py b/zenmap/radialnet/gui/RadialNet.py index 1fef3bd14..aa68d3819 100644 --- a/zenmap/radialnet/gui/RadialNet.py +++ b/zenmap/radialnet/gui/RadialNet.py @@ -259,7 +259,7 @@ class RadialNet(gtk.DrawingArea): @param function: Protected function """ def check_graph_status(*args): - if args[0].__graph == None: + if args[0].__graph is None: return False return function(*args) @@ -449,7 +449,7 @@ class RadialNet(gtk.DrawingArea): self.__layout = layout - if self.__graph != None: + if self.__graph is not None: self.__animating = True self.__calc_interpolation(self.__graph.get_main_node()) @@ -703,7 +703,7 @@ class RadialNet(gtk.DrawingArea): if self.__animating == True: return False - if result != None: + if result is not None: node, point = result main_node = self.__graph.get_main_node() @@ -727,7 +727,7 @@ class RadialNet(gtk.DrawingArea): if self.__animating == True: return False - if result != None: + if result is not None: node, point = result main_node = self.__graph.get_main_node() @@ -755,7 +755,7 @@ class RadialNet(gtk.DrawingArea): # setting to show node's region elif self.__pointer_status == POINTER_FILL and event.button == 1: - if result != None: + if result is not None: node, point = result @@ -773,7 +773,7 @@ class RadialNet(gtk.DrawingArea): if event.button == 3: self.__button3_press = True - if result != None: + if result is not None: xw, yw = self.window.get_origin() node, point = result @@ -840,7 +840,7 @@ class RadialNet(gtk.DrawingArea): result = self.__get_node_by_coordinate(self.get_pointer()) - if result != None: + if result is not None: result[0].set_draw_info({'over': True}) elif self.__button1_press == True and self.__last_motion_point != None: @@ -921,7 +921,7 @@ class RadialNet(gtk.DrawingArea): not_grouped = not node.get_draw_info('grouped') - if node.get_draw_info('region') != None and not_grouped: + if node.get_draw_info('region') is not None and not_grouped: x, y = node.get_cartesian_coordinate() xc, yc = self.__center_of_widget @@ -1002,7 +1002,7 @@ class RadialNet(gtk.DrawingArea): last_group = self.__last_group_node groups = [a_group, b_group] - if last_group in groups and last_group != None: + if last_group in groups and last_group is not None: self.__draw_edge(context, edge) elif not a_is_grouped or not b_is_grouped: @@ -1051,7 +1051,7 @@ class RadialNet(gtk.DrawingArea): context.set_source_rgba(0.1, 0.5, 1.0, 0.8) # calculating line thickness by latency - if latency != None: + if latency is not None: min = self.__graph.get_min_edge_mean_weight() max = self.__graph.get_max_edge_mean_weight() @@ -1077,7 +1077,7 @@ class RadialNet(gtk.DrawingArea): if not self.__animating and self.__show_latency: - if latency != None: + if latency is not None: context.set_font_size(8) context.set_line_width(1) @@ -1208,10 +1208,10 @@ class RadialNet(gtk.DrawingArea): hostname = node.get_info('hostname') - if hostname != None and self.__show_hostname: + if hostname is not None and self.__show_hostname: context.show_text(hostname) - elif node.get_info('ip') != None: + elif node.get_info('ip') is not None: context.show_text(node.get_info('ip')) context.set_line_width(1) @@ -1255,7 +1255,7 @@ class RadialNet(gtk.DrawingArea): # deep group check group = node.get_draw_info('group_node') - while group.get_draw_info('group_node') != None: + while group.get_draw_info('group_node') is not None: group = group.get_draw_info('group_node') ring = group.get_draw_info('ring') @@ -1458,7 +1458,7 @@ class RadialNet(gtk.DrawingArea): self.__weighted_layout() # rotating focus' children to keep orientation - if reference != None: + if reference is not None: father, angle = reference theta = father.get_coordinate_theta() @@ -1509,7 +1509,7 @@ class RadialNet(gtk.DrawingArea): father = focus.get_draw_info('father') # calculate nodes positions (and father orientation)? - if father != None: + if father is not None: xa, ya = father.get_cartesian_coordinate() xb, yb = focus.get_cartesian_coordinate() @@ -1729,10 +1729,7 @@ class RadialNet(gtk.DrawingArea): def is_empty(self): """ """ - if self.__graph == None: - return True - - return False + return self.__graph is None def is_in_animation(self): """ @@ -1830,7 +1827,7 @@ class NetNode(Node): if len(host.osmatches) > 0 and \ host.osmatches[0]["accuracy"] != "" and \ host.osmatches[0]["name"] != "": - if os == None: + if os is None: os = {} os["matches"] = host.osmatches os["matches"][0]["db_line"] = 0 # not supported @@ -1850,7 +1847,7 @@ class NetNode(Node): # ports_used if len(host.ports_used) > 0: - if os == None: + if os is None: os = {} os_portsused = [] @@ -2039,7 +2036,7 @@ class NetNode(Node): @rtype: mixed @return: The requested information """ - if info == None: + if info is None: return self.__draw_info return self.__draw_info.get(info) diff --git a/zenmap/radialnet/radialnet.pyw b/zenmap/radialnet/radialnet.pyw index c40c3b332..2c57ff886 100755 --- a/zenmap/radialnet/radialnet.pyw +++ b/zenmap/radialnet/radialnet.pyw @@ -170,7 +170,7 @@ if __name__ == '__main__': file = argvh.get_option('-f') - if file == None: + if file is None: print USAGE sys.exit(0) diff --git a/zenmap/zenmapCore/NetworkInventory.py b/zenmap/zenmapCore/NetworkInventory.py index b99b3434b..c065a2fde 100644 --- a/zenmap/zenmapCore/NetworkInventory.py +++ b/zenmap/zenmapCore/NetworkInventory.py @@ -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(): diff --git a/zenmap/zenmapCore/NmapCommand.py b/zenmap/zenmapCore/NmapCommand.py index 94bbd0d4c..a71a3968b 100644 --- a/zenmap/zenmapCore/NmapCommand.py +++ b/zenmap/zenmapCore/NmapCommand.py @@ -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 diff --git a/zenmap/zenmapCore/NmapOptions.py b/zenmap/zenmapCore/NmapOptions.py index 5a24bbf5d..7e80035ff 100644 --- a/zenmap/zenmapCore/NmapOptions.py +++ b/zenmap/zenmapCore/NmapOptions.py @@ -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): diff --git a/zenmap/zenmapCore/NmapParser.py b/zenmap/zenmapCore/NmapParser.py index db2716e94..a54993a3d 100644 --- a/zenmap/zenmapCore/NmapParser.py +++ b/zenmap/zenmapCore/NmapParser.py @@ -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 diff --git a/zenmap/zenmapCore/SearchResult.py b/zenmap/zenmapCore/SearchResult.py index 8a19a0492..fb550439b 100644 --- a/zenmap/zenmapCore/SearchResult.py +++ b/zenmap/zenmapCore/SearchResult.py @@ -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 diff --git a/zenmap/zenmapCore/UmitConf.py b/zenmap/zenmapCore/UmitConf.py index adc5a1b1b..80afedb2f 100644 --- a/zenmap/zenmapCore/UmitConf.py +++ b/zenmap/zenmapCore/UmitConf.py @@ -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: diff --git a/zenmap/zenmapGUI/OptionBuilder.py b/zenmap/zenmapGUI/OptionBuilder.py index b62fdf54e..8d940c49e 100644 --- a/zenmap/zenmapGUI/OptionBuilder.py +++ b/zenmap/zenmapGUI/OptionBuilder.py @@ -398,7 +398,7 @@ class OptionTab(object): def fill_table(self, table, expand_fill=True): yopt = (0, gtk.EXPAND | gtk.FILL)[expand_fill] for y, widget in enumerate(self.widgets_list): - if widget[1] == None: + if widget[1] is None: table.attach(widget[0], 0, 2, y, y + 1, yoptions=yopt) else: table.attach(widget[0], 0, 1, y, y + 1, yoptions=yopt) diff --git a/zenmap/zenmapGUI/SearchGUI.py b/zenmap/zenmapGUI/SearchGUI.py index c51b062a6..4983597f9 100644 --- a/zenmap/zenmapGUI/SearchGUI.py +++ b/zenmap/zenmapGUI/SearchGUI.py @@ -439,7 +439,7 @@ class SearchGUI(gtk.VBox, object): self.search_entry.set_sensitive(True) def close(self): - if self.expr_window != None: + if self.expr_window is not None: self.expr_window.close() def add_criterion(self, caller): @@ -854,11 +854,11 @@ class DateSubcriterion(Subcriterion): self.fuzzies = argument.count("~") argument = argument.replace("~", "") self.minus_notation = False - if re.match("\d\d\d\d-\d\d-\d\d$", argument) != None: + if re.match("\d\d\d\d-\d\d-\d\d$", argument) is not None: year, month, day = argument.split("-") self.date = datetime.date(int(year), int(month), int(day)) self.argument = argument - elif re.match("[-|\+]\d+$", argument) != None: + elif re.match("[-|\+]\d+$", argument) is not None: # Convert the date from the "-n" notation into YYYY-MM-DD parsed_date = datetime.date.fromordinal( datetime.date.today().toordinal() + int(argument)) diff --git a/zenmap/zenmapGUI/higwidgets/higspinner.py b/zenmap/zenmapGUI/higwidgets/higspinner.py index 49e574151..48d358189 100644 --- a/zenmap/zenmapGUI/higwidgets/higspinner.py +++ b/zenmap/zenmapGUI/higwidgets/higspinner.py @@ -240,17 +240,17 @@ class HIGSpinnerCache: """Loads an animated icon by doing a lookup on the icon theme.""" # If user do not choose a icon_name, use the default one - if icon_name == None: + if icon_name is None: icon_name = self.default_animated_icon_name # Even the default one (now on icon_name) might not be available - if icon_name == None: + if icon_name is None: raise AnimatedIconNotFound # Try to lookup the icon icon_info = self.icon_theme.lookup_icon(icon_name, -1, 0) # Even if icon_name exists, it might not be found by lookup - if icon_info == None: + if icon_info is None: raise AnimatedIconNotFound # Base size is, according to PyGTK docs: @@ -291,7 +291,7 @@ class HIGSpinnerCache: def load_static_from_filename(self, filename, key_name=None): icon_pixbuf = gtk.gdk.pixbuf_new_from_file(filename) - if key_name == None: + if key_name is None: key_name = filename.split(".")[0] self.spinner_images.add_static_pixbuf(key_name, icon_pixbuf) @@ -420,7 +420,7 @@ class HIGSpinner(gtk.EventBox): def do_expose_event(self, event): #self.chain(event) - if self.cache.spinner_images.rest_pixbuf == None: + if self.cache.spinner_images.rest_pixbuf is None: raise RestPixbufNotFound self.__select_pixbuf() @@ -437,7 +437,7 @@ class HIGSpinner(gtk.EventBox): dest = event.area.intersect(pix_area) # If a graphic context doesn't not exist yet, create one - if self.gc == None: + if self.gc is None: self.gc = gtk.gdk.GC(self.window) #gc = self.gc