diff --git a/zenmap/radialnet/gui/ControlWidget.py b/zenmap/radialnet/gui/ControlWidget.py index 7291fb7ba..1185c7696 100644 --- a/zenmap/radialnet/gui/ControlWidget.py +++ b/zenmap/radialnet/gui/ControlWidget.py @@ -344,7 +344,7 @@ class ControlVariableWidget(gtk.DrawingArea): @rtype: boolean @return: Indicator of the event propagation """ - if self.__active_increment == True: + if self.__active_increment: xc, yc = self.__center_of_widget x, _ = self.get_pointer() @@ -409,7 +409,7 @@ class ControlVariableWidget(gtk.DrawingArea): self.context.arc(xc + self.__pointer_position, yc + self.__radius, self.__radius, 0, 2 * math.pi) - if self.__active_increment == True: + if self.__active_increment: self.context.set_source_rgb(0.0, 0.0, 0.0) else: self.context.set_source_rgb(1.0, 1.0, 1.0) @@ -423,10 +423,7 @@ class ControlVariableWidget(gtk.DrawingArea): xc, yc = self.__center_of_widget center = (xc, yc + self.__radius) - if geometry.is_in_circle(pointer, 6, center) == True: - return True - - return False + return geometry.is_in_circle(pointer, 6, center) def __increment_value(self): """ @@ -435,7 +432,7 @@ class ControlVariableWidget(gtk.DrawingArea): self.queue_draw() - if self.__active_increment == True: + if self.__active_increment: gobject.timeout_add(self.__increment_time, self.__increment_value) @@ -1084,7 +1081,7 @@ class ControlNavigation(gtk.DrawingArea): direction = False - if self.__rotate_is_clicked(pointer) == True: + if self.__rotate_is_clicked(pointer): event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) self.__rotating = True @@ -1097,7 +1094,7 @@ class ControlNavigation(gtk.DrawingArea): self.__moving = direction self.__move_in_direction(direction) - if self.__center_is_clicked(pointer) == True: + if self.__center_is_clicked(pointer): event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) self.__centering = True @@ -1145,7 +1142,7 @@ class ControlNavigation(gtk.DrawingArea): status = not self.radialnet.is_in_animation() status = status and not self.radialnet.is_empty() - if self.__rotating == True and status: + if self.__rotating and status: r, t = self.__rotate_node.get_coordinate() t = math.degrees(math.atan2(yc - y, x - xc)) @@ -1206,7 +1203,7 @@ class ControlNavigation(gtk.DrawingArea): self.context.set_dash([1, 0]) self.context.arc(xc + x, yc - y, self.__rotate_radius, 0, 2 * math.pi) - if self.__rotating == True: + if self.__rotating: self.context.set_source_rgb(0.0, 0.0, 0.0) else: @@ -1256,7 +1253,7 @@ class ControlNavigation(gtk.DrawingArea): self.context.arc(xc, yc, 6, 0, 2 * math.pi) - if self.__centering == True: + if self.__centering: self.context.set_source_rgb(0.0, 0.0, 0.0) else: self.context.set_source_rgb(1.0, 1.0, 1.0) @@ -1310,24 +1307,13 @@ class ControlNavigation(gtk.DrawingArea): xc, yc = self.__center_of_widget center = (xc + xn, yc - yn) - result = geometry.is_in_circle(pointer, self.__rotate_radius, center) - - if result == True: - return True - - return False + return geometry.is_in_circle(pointer, self.__rotate_radius, center) def __center_is_clicked(self, pointer): """ """ - result = geometry.is_in_circle(pointer, - self.__move_radius, - self.__center_of_widget) - - if result == True: - return True - - return False + return geometry.is_in_circle(pointer, self.__move_radius, + self.__center_of_widget) def __move_is_clicked(self, pointer): """ @@ -1341,11 +1327,7 @@ class ControlNavigation(gtk.DrawingArea): x, y = pc.to_cartesian() center = (xc + x, yc - y) - result = geometry.is_in_circle(pointer, - self.__move_radius, - center) - - if result == True: + if geometry.is_in_circle(pointer, self.__move_radius, center): return i return None diff --git a/zenmap/radialnet/gui/RadialNet.py b/zenmap/radialnet/gui/RadialNet.py index aa68d3819..6efef617c 100644 --- a/zenmap/radialnet/gui/RadialNet.py +++ b/zenmap/radialnet/gui/RadialNet.py @@ -272,7 +272,7 @@ class RadialNet(gtk.DrawingArea): @param function: Protected function """ def check_animation_status(*args): - if args[0].__animating == True: + if args[0].__animating: return False return function(*args) @@ -700,7 +700,7 @@ class RadialNet(gtk.DrawingArea): if self.__pointer_status == POINTER_JUMP_TO and event.button == 1: # prevent double animation - if self.__animating == True: + if self.__animating: return False if result is not None: @@ -710,7 +710,7 @@ class RadialNet(gtk.DrawingArea): if node != main_node: - if node.get_draw_info('group') == True: + if node.get_draw_info('group'): node.set_draw_info({'group': False}) node.set_subtree_info({'grouped': False, @@ -724,7 +724,7 @@ class RadialNet(gtk.DrawingArea): elif self.__pointer_status == POINTER_GROUP and event.button == 1: # prevent group on animation - if self.__animating == True: + if self.__animating: return False if result is not None: @@ -734,7 +734,7 @@ class RadialNet(gtk.DrawingArea): if node != main_node: - if node.get_draw_info('group') == True: + if node.get_draw_info('group'): node.set_draw_info({'group': False}) node.set_subtree_info({'grouped': False, @@ -843,7 +843,7 @@ class RadialNet(gtk.DrawingArea): if result is not None: result[0].set_draw_info({'over': True}) - elif self.__button1_press == True and self.__last_motion_point != None: + elif self.__button1_press and self.__last_motion_point is not None: ax, ay = pointer ox, oy = self.__last_motion_point @@ -970,7 +970,7 @@ class RadialNet(gtk.DrawingArea): context.stroke() # drawing network rings - if self.__show_ring == True and self.__animating != True: + if self.__show_ring and not self.__animating: for i in range(1, self.__number_of_rings): @@ -1103,7 +1103,7 @@ class RadialNet(gtk.DrawingArea): y_gap = 0 # draw group indication - if node.get_draw_info('group') == True: + if node.get_draw_info('group'): x_gap += 5 @@ -1129,7 +1129,7 @@ class RadialNet(gtk.DrawingArea): context.stroke() # draw over node - if node.get_draw_info('over') == True: + if node.get_draw_info('over'): context.set_line_width(0) @@ -1250,7 +1250,7 @@ class RadialNet(gtk.DrawingArea): """ for node in self.__sorted_nodes: - if node.get_draw_info('grouped') == True: + if node.get_draw_info('grouped'): # deep group check group = node.get_draw_info('group_node') @@ -1273,7 +1273,7 @@ class RadialNet(gtk.DrawingArea): for node in self.__graph.get_nodes(): - if node.get_draw_info('grouped') == True: + if node.get_draw_info('grouped'): continue ax, ay = self.__translation @@ -1285,11 +1285,11 @@ class RadialNet(gtk.DrawingArea): type = node.get_info('device_type') if type in SQUARE_TYPES: - if geometry.is_in_square(point, radius, center) == True: + if geometry.is_in_square(point, radius, center): return node, center else: - if geometry.is_in_circle(point, radius, center) == True: + if geometry.is_in_circle(point, radius, center): return node, center return None @@ -1361,7 +1361,7 @@ class RadialNet(gtk.DrawingArea): # check group influence in number of rings for node in tmp_nodes: - if node.get_draw_info('grouped') != True: + if not node.get_draw_info('grouped'): number_of_needed_rings += 1 break @@ -1391,7 +1391,7 @@ class RadialNet(gtk.DrawingArea): children = set() for child in node.get_draw_info('children'): - if child.get_draw_info('grouped') != True: + if not child.get_draw_info('grouped'): children.add(child) new_nodes.add(child) @@ -1428,7 +1428,7 @@ class RadialNet(gtk.DrawingArea): children = set() for child in node.get_draw_info('children'): - if child.get_draw_info('grouped') != True: + if not child.get_draw_info('grouped'): children.add(child) new_nodes.add(child) @@ -1534,7 +1534,7 @@ class RadialNet(gtk.DrawingArea): l2di = Linear2DInterpolator() # change grouped nodes coordinate - if node.get_draw_info('grouped') == True: + if node.get_draw_info('grouped'): group_node = node.get_draw_info('group_node') a, b = group_node.get_draw_info('final_coordinate') @@ -2070,7 +2070,7 @@ class NetNode(Node): child.set_draw_info(info) - if child.get_draw_info('group') != True: + if not child.get_draw_info('group'): child.set_subtree_info(info) def calc_needed_space(self): @@ -2081,7 +2081,7 @@ class NetNode(Node): sum_angle = 0 own_angle = 0 - if number_of_children > 0 and self.get_draw_info('group') != True: + if number_of_children > 0 and not self.get_draw_info('group'): for child in self.get_draw_info('children'):