1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 05:31:31 +00:00

Replace explicit X == True/False with X/not X

This commit is contained in:
dmiller
2014-01-09 16:47:24 +00:00
parent 51b143353b
commit bc47cb3d97
2 changed files with 32 additions and 50 deletions

View File

@@ -344,7 +344,7 @@ class ControlVariableWidget(gtk.DrawingArea):
@rtype: boolean @rtype: boolean
@return: Indicator of the event propagation @return: Indicator of the event propagation
""" """
if self.__active_increment == True: if self.__active_increment:
xc, yc = self.__center_of_widget xc, yc = self.__center_of_widget
x, _ = self.get_pointer() x, _ = self.get_pointer()
@@ -409,7 +409,7 @@ class ControlVariableWidget(gtk.DrawingArea):
self.context.arc(xc + self.__pointer_position, self.context.arc(xc + self.__pointer_position,
yc + self.__radius, yc + self.__radius,
self.__radius, 0, 2 * math.pi) 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) self.context.set_source_rgb(0.0, 0.0, 0.0)
else: else:
self.context.set_source_rgb(1.0, 1.0, 1.0) 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 xc, yc = self.__center_of_widget
center = (xc, yc + self.__radius) center = (xc, yc + self.__radius)
if geometry.is_in_circle(pointer, 6, center) == True: return geometry.is_in_circle(pointer, 6, center)
return True
return False
def __increment_value(self): def __increment_value(self):
""" """
@@ -435,7 +432,7 @@ class ControlVariableWidget(gtk.DrawingArea):
self.queue_draw() self.queue_draw()
if self.__active_increment == True: if self.__active_increment:
gobject.timeout_add(self.__increment_time, gobject.timeout_add(self.__increment_time,
self.__increment_value) self.__increment_value)
@@ -1084,7 +1081,7 @@ class ControlNavigation(gtk.DrawingArea):
direction = False 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)) event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
self.__rotating = True self.__rotating = True
@@ -1097,7 +1094,7 @@ class ControlNavigation(gtk.DrawingArea):
self.__moving = direction self.__moving = direction
self.__move_in_direction(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)) event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
self.__centering = True self.__centering = True
@@ -1145,7 +1142,7 @@ class ControlNavigation(gtk.DrawingArea):
status = not self.radialnet.is_in_animation() status = not self.radialnet.is_in_animation()
status = status and not self.radialnet.is_empty() 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() r, t = self.__rotate_node.get_coordinate()
t = math.degrees(math.atan2(yc - y, x - xc)) 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.set_dash([1, 0])
self.context.arc(xc + x, yc - y, self.__rotate_radius, 0, 2 * math.pi) 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) self.context.set_source_rgb(0.0, 0.0, 0.0)
else: else:
@@ -1256,7 +1253,7 @@ class ControlNavigation(gtk.DrawingArea):
self.context.arc(xc, yc, 6, 0, 2 * math.pi) 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) self.context.set_source_rgb(0.0, 0.0, 0.0)
else: else:
self.context.set_source_rgb(1.0, 1.0, 1.0) 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 xc, yc = self.__center_of_widget
center = (xc + xn, yc - yn) center = (xc + xn, yc - yn)
result = geometry.is_in_circle(pointer, self.__rotate_radius, center) return geometry.is_in_circle(pointer, self.__rotate_radius, center)
if result == True:
return True
return False
def __center_is_clicked(self, pointer): def __center_is_clicked(self, pointer):
""" """
""" """
result = geometry.is_in_circle(pointer, return geometry.is_in_circle(pointer, self.__move_radius,
self.__move_radius, self.__center_of_widget)
self.__center_of_widget)
if result == True:
return True
return False
def __move_is_clicked(self, pointer): def __move_is_clicked(self, pointer):
""" """
@@ -1341,11 +1327,7 @@ class ControlNavigation(gtk.DrawingArea):
x, y = pc.to_cartesian() x, y = pc.to_cartesian()
center = (xc + x, yc - y) center = (xc + x, yc - y)
result = geometry.is_in_circle(pointer, if geometry.is_in_circle(pointer, self.__move_radius, center):
self.__move_radius,
center)
if result == True:
return i return i
return None return None

View File

@@ -272,7 +272,7 @@ class RadialNet(gtk.DrawingArea):
@param function: Protected function @param function: Protected function
""" """
def check_animation_status(*args): def check_animation_status(*args):
if args[0].__animating == True: if args[0].__animating:
return False return False
return function(*args) return function(*args)
@@ -700,7 +700,7 @@ class RadialNet(gtk.DrawingArea):
if self.__pointer_status == POINTER_JUMP_TO and event.button == 1: if self.__pointer_status == POINTER_JUMP_TO and event.button == 1:
# prevent double animation # prevent double animation
if self.__animating == True: if self.__animating:
return False return False
if result is not None: if result is not None:
@@ -710,7 +710,7 @@ class RadialNet(gtk.DrawingArea):
if node != main_node: 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_draw_info({'group': False})
node.set_subtree_info({'grouped': 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: elif self.__pointer_status == POINTER_GROUP and event.button == 1:
# prevent group on animation # prevent group on animation
if self.__animating == True: if self.__animating:
return False return False
if result is not None: if result is not None:
@@ -734,7 +734,7 @@ class RadialNet(gtk.DrawingArea):
if node != main_node: 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_draw_info({'group': False})
node.set_subtree_info({'grouped': False, node.set_subtree_info({'grouped': False,
@@ -843,7 +843,7 @@ class RadialNet(gtk.DrawingArea):
if result is not None: if result is not None:
result[0].set_draw_info({'over': True}) 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 ax, ay = pointer
ox, oy = self.__last_motion_point ox, oy = self.__last_motion_point
@@ -970,7 +970,7 @@ class RadialNet(gtk.DrawingArea):
context.stroke() context.stroke()
# drawing network rings # 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): for i in range(1, self.__number_of_rings):
@@ -1103,7 +1103,7 @@ class RadialNet(gtk.DrawingArea):
y_gap = 0 y_gap = 0
# draw group indication # draw group indication
if node.get_draw_info('group') == True: if node.get_draw_info('group'):
x_gap += 5 x_gap += 5
@@ -1129,7 +1129,7 @@ class RadialNet(gtk.DrawingArea):
context.stroke() context.stroke()
# draw over node # draw over node
if node.get_draw_info('over') == True: if node.get_draw_info('over'):
context.set_line_width(0) context.set_line_width(0)
@@ -1250,7 +1250,7 @@ class RadialNet(gtk.DrawingArea):
""" """
for node in self.__sorted_nodes: for node in self.__sorted_nodes:
if node.get_draw_info('grouped') == True: if node.get_draw_info('grouped'):
# deep group check # deep group check
group = node.get_draw_info('group_node') group = node.get_draw_info('group_node')
@@ -1273,7 +1273,7 @@ class RadialNet(gtk.DrawingArea):
for node in self.__graph.get_nodes(): for node in self.__graph.get_nodes():
if node.get_draw_info('grouped') == True: if node.get_draw_info('grouped'):
continue continue
ax, ay = self.__translation ax, ay = self.__translation
@@ -1285,11 +1285,11 @@ class RadialNet(gtk.DrawingArea):
type = node.get_info('device_type') type = node.get_info('device_type')
if type in SQUARE_TYPES: 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 return node, center
else: else:
if geometry.is_in_circle(point, radius, center) == True: if geometry.is_in_circle(point, radius, center):
return node, center return node, center
return None return None
@@ -1361,7 +1361,7 @@ class RadialNet(gtk.DrawingArea):
# check group influence in number of rings # check group influence in number of rings
for node in tmp_nodes: for node in tmp_nodes:
if node.get_draw_info('grouped') != True: if not node.get_draw_info('grouped'):
number_of_needed_rings += 1 number_of_needed_rings += 1
break break
@@ -1391,7 +1391,7 @@ class RadialNet(gtk.DrawingArea):
children = set() children = set()
for child in node.get_draw_info('children'): 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) children.add(child)
new_nodes.add(child) new_nodes.add(child)
@@ -1428,7 +1428,7 @@ class RadialNet(gtk.DrawingArea):
children = set() children = set()
for child in node.get_draw_info('children'): 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) children.add(child)
new_nodes.add(child) new_nodes.add(child)
@@ -1534,7 +1534,7 @@ class RadialNet(gtk.DrawingArea):
l2di = Linear2DInterpolator() l2di = Linear2DInterpolator()
# change grouped nodes coordinate # 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') group_node = node.get_draw_info('group_node')
a, b = group_node.get_draw_info('final_coordinate') a, b = group_node.get_draw_info('final_coordinate')
@@ -2070,7 +2070,7 @@ class NetNode(Node):
child.set_draw_info(info) child.set_draw_info(info)
if child.get_draw_info('group') != True: if not child.get_draw_info('group'):
child.set_subtree_info(info) child.set_subtree_info(info)
def calc_needed_space(self): def calc_needed_space(self):
@@ -2081,7 +2081,7 @@ class NetNode(Node):
sum_angle = 0 sum_angle = 0
own_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'): for child in self.get_draw_info('children'):