1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 21:51:28 +00:00

Apply PEP 8 style guidance to zenmap

Using the pep8 tool (https://pypi.python.org/pypi/pep8), fixed the
following style issues:

Count   Issue
11      E201 whitespace after '['
8       E203 whitespace before ','
41      E211 whitespace before '('
11      E221 multiple spaces before operator
61      E225 missing whitespace around operator
237     E231 missing whitespace after ':'
91      E251 no spaces around keyword / parameter equals
19      E261 at least two spaces before inline comment
41      E301 expected 1 blank line, found 0
200     E302 expected 2 blank lines, found 1
356     E303 too many blank lines (2)
563     E501 line too long (106 characters)
39      E701 multiple statements on one line (colon)
13      E702 multiple statements on one line (semicolon)
4       W291 trailing whitespace
2       W293 blank line contains whitespace
8       W391 blank line at end of file
21      W601 .has_key() is deprecated, use 'in'
2       W602 deprecated form of raising exception

The remaining issues are long lines due to very deep data structures. I
chose not to alter them, as it would involve backslash-continuation
where whitespace is not permitted:

./zenmapGUI/ScanInterface.py:323:80: E501 line too long (90 characters)
./zenmapGUI/ScanInterface.py:456:80: E501 line too long (84 characters)
./zenmapGUI/ScanInterface.py:464:80: E501 line too long (84 characters)
./zenmapGUI/ScanInterface.py:472:80: E501 line too long (122 characters)
./zenmapGUI/ScanInterface.py:479:80: E501 line too long (122 characters)
./zenmapGUI/ScanInterface.py:920:80: E501 line too long (94 characters)
./zenmapGUI/ScanInterface.py:923:80: E501 line too long (93 characters)
./zenmapGUI/MainWindow.py:575:80: E501 line too long (99 characters)
./zenmapGUI/MainWindow.py:906:80: E501 line too long (99 characters)
This commit is contained in:
dmiller
2014-01-08 19:50:22 +00:00
parent 9210a7f1fa
commit 5c662fffdc
100 changed files with 2287 additions and 1814 deletions

View File

@@ -143,7 +143,6 @@ OPTIONS = ['address',
REFRESH_RATE = 500
class ControlWidget(BWVBox):
"""
"""
@@ -157,7 +156,6 @@ class ControlWidget(BWVBox):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -179,6 +177,7 @@ def try_set_tooltip_text(widget, text):
# The set_tooltip_text method was introduced in PyGTK 2.12.
pass
class ControlAction(BWExpander):
"""
"""
@@ -192,7 +191,6 @@ class ControlAction(BWExpander):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -253,7 +251,6 @@ class ControlAction(BWExpander):
self.__region_color.set_no_show_all(True)
self.__region_color.hide()
def __change_pointer(self, widget, pointer):
"""
"""
@@ -265,14 +262,12 @@ class ControlAction(BWExpander):
else:
self.__region_color.hide()
def __change_region(self, widget):
"""
"""
self.radialnet.set_region_color(self.__region_color.get_active())
class ControlVariableWidget(gtk.DrawingArea):
"""
"""
@@ -307,7 +302,6 @@ class ControlVariableWidget(gtk.DrawingArea):
gobject.timeout_add(REFRESH_RATE, self.verify_value)
def verify_value(self):
"""
"""
@@ -318,7 +312,6 @@ class ControlVariableWidget(gtk.DrawingArea):
return True
def button_press(self, widget, event):
"""
"""
@@ -331,7 +324,6 @@ class ControlVariableWidget(gtk.DrawingArea):
self.__active_increment = True
self.__increment_value()
def button_release(self, widget, event):
"""
"""
@@ -342,7 +334,6 @@ class ControlVariableWidget(gtk.DrawingArea):
self.queue_draw()
def motion_notify(self, widget, event):
"""
Drawing callback
@@ -363,7 +354,6 @@ class ControlVariableWidget(gtk.DrawingArea):
self.queue_draw()
def expose(self, widget, event):
"""
Drawing callback
@@ -381,7 +371,6 @@ class ControlVariableWidget(gtk.DrawingArea):
return True
def __draw(self):
"""
"""
@@ -394,7 +383,7 @@ class ControlVariableWidget(gtk.DrawingArea):
# draw line
self.context.set_line_width(1)
self.context.set_dash([1,2])
self.context.set_dash([1, 2])
self.context.move_to(self.__radius,
yc + self.__radius)
self.context.line_to(2 * xc - 5,
@@ -402,7 +391,7 @@ class ControlVariableWidget(gtk.DrawingArea):
self.context.stroke()
# draw text
self.context.set_dash([1,0])
self.context.set_dash([1, 0])
self.context.set_font_size(10)
width = self.context.text_extents(self.__variable_name)[2]
@@ -428,7 +417,6 @@ class ControlVariableWidget(gtk.DrawingArea):
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.stroke()
def __button_is_clicked(self, pointer):
"""
"""
@@ -440,7 +428,6 @@ class ControlVariableWidget(gtk.DrawingArea):
return False
def __increment_value(self):
"""
"""
@@ -453,20 +440,17 @@ class ControlVariableWidget(gtk.DrawingArea):
gobject.timeout_add(self.__increment_time,
self.__increment_value)
def set_value_function(self, value):
"""
"""
self.__value = value
def set_update_function(self, update):
"""
"""
self.__update = update
class ControlVariable(BWHBox):
"""
"""
@@ -485,7 +469,6 @@ class ControlVariable(BWHBox):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -516,14 +499,12 @@ class ControlVariable(BWHBox):
self.bw_pack_start_expand_fill(self.__control)
self.bw_pack_start_noexpand_nofill(self.__right_button)
def __pressed(self, widget, increment):
"""
"""
self.__increment = True
self.__increment_function(increment)
def __increment_function(self, increment):
"""
"""
@@ -536,15 +517,12 @@ class ControlVariable(BWHBox):
self.__increment_function,
increment)
def __released(self, widget):
"""
"""
self.__increment = False
class ControlFisheye(BWVBox):
"""
"""
@@ -559,7 +537,6 @@ class ControlFisheye(BWVBox):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -606,7 +583,6 @@ class ControlFisheye(BWVBox):
gobject.timeout_add(REFRESH_RATE, self.__update_fisheye)
def __update_fisheye(self):
"""
"""
@@ -648,7 +624,6 @@ class ControlFisheye(BWVBox):
return True
def active_fisheye(self):
"""
"""
@@ -656,13 +631,11 @@ class ControlFisheye(BWVBox):
self.__change_ring()
self.__change_interest()
def deactive_fisheye(self):
"""
"""
self.radialnet.set_fisheye(False)
def __change_ring(self, widget=None):
"""
"""
@@ -671,7 +644,6 @@ class ControlFisheye(BWVBox):
else:
self.__ring.set_value(self.radialnet.get_fisheye_ring())
def __change_interest(self, widget=None):
"""
"""
@@ -680,7 +652,6 @@ class ControlFisheye(BWVBox):
else:
self.__interest.set_value(self.radialnet.get_fisheye_interest())
def __change_spread(self, widget=None):
"""
"""
@@ -690,7 +661,6 @@ class ControlFisheye(BWVBox):
self.__spread.set_value(self.radialnet.get_fisheye_spread())
class ControlInterpolation(BWExpander):
"""
"""
@@ -703,14 +673,14 @@ class ControlInterpolation(BWExpander):
self.__create_widgets()
def __create_widgets(self):
"""
"""
self.__vbox = BWVBox()
self.__cartesian_radio = gtk.RadioButton(None, _('Cartesian'))
self.__polar_radio = gtk.RadioButton(self.__cartesian_radio, _('Polar'))
self.__polar_radio = gtk.RadioButton(
self.__cartesian_radio, _('Polar'))
self.__cartesian_radio.connect('toggled',
self.__change_system,
INTERPOLATION_CARTESIAN)
@@ -741,7 +711,6 @@ class ControlInterpolation(BWExpander):
gobject.timeout_add(REFRESH_RATE, self.__update_animation)
def __update_animation(self):
"""
"""
@@ -755,7 +724,6 @@ class ControlInterpolation(BWExpander):
return True
def __change_system(self, widget, value):
"""
"""
@@ -769,7 +737,6 @@ class ControlInterpolation(BWExpander):
else:
self.__polar_radio.set_active(True)
def __change_frames(self, widget):
"""
"""
@@ -777,7 +744,6 @@ class ControlInterpolation(BWExpander):
self.__frames.set_value(self.radialnet.get_number_of_frames())
class ControlLayout(BWExpander):
"""
"""
@@ -790,7 +756,6 @@ class ControlLayout(BWExpander):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -811,7 +776,6 @@ class ControlLayout(BWExpander):
self.__check_layout()
def __check_layout(self):
"""
"""
@@ -823,14 +787,12 @@ class ControlLayout(BWExpander):
return True
def __force_update(self, widget):
"""
"""
self.__fisheye_ring = self.radialnet.get_fisheye_ring()
self.radialnet.update_layout()
def __change_layout(self, widget):
"""
"""
@@ -841,7 +803,6 @@ class ControlLayout(BWExpander):
self.__check_layout()
class ControlRingGap(BWVBox):
"""
"""
@@ -854,7 +815,6 @@ class ControlRingGap(BWVBox):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -878,7 +838,6 @@ class ControlRingGap(BWVBox):
self.bw_pack_start_noexpand_nofill(self.__radius)
self.bw_pack_start_noexpand_nofill(self.__lower_hbox)
def __change_lower(self, widget):
"""
"""
@@ -886,7 +845,6 @@ class ControlRingGap(BWVBox):
self.__adjustment.set_value(self.radialnet.get_min_ring_gap())
class ControlOptions(BWScrolledWindow):
"""
"""
@@ -902,7 +860,6 @@ class ControlOptions(BWScrolledWindow):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -943,23 +900,23 @@ class ControlOptions(BWScrolledWindow):
gobject.timeout_add(REFRESH_RATE, self.__update_options)
def __update_options(self):
"""
"""
model = self.__liststore
model[OPTIONS.index('address')][0] = self.radialnet.get_show_address()
model[OPTIONS.index('hostname')][0] = self.radialnet.get_show_hostname()
model[OPTIONS.index('hostname')][0] = \
self.radialnet.get_show_hostname()
model[OPTIONS.index('icon')][0] = self.radialnet.get_show_icon()
model[OPTIONS.index('latency')][0] = self.radialnet.get_show_latency()
model[OPTIONS.index('ring')][0] = self.radialnet.get_show_ring()
model[OPTIONS.index('region')][0] = self.radialnet.get_show_region()
model[OPTIONS.index('slow in/out')][0] = self.radialnet.get_slow_inout()
model[OPTIONS.index('slow in/out')][0] = \
self.radialnet.get_slow_inout()
return True
def __change_option(self, cell, option, model):
"""
"""
@@ -988,7 +945,6 @@ class ControlOptions(BWScrolledWindow):
self.radialnet.set_slow_inout(model[option][0])
class ControlView(BWExpander):
"""
"""
@@ -1002,7 +958,6 @@ class ControlView(BWExpander):
self.__create_widgets()
def __create_widgets(self):
"""
"""
@@ -1026,7 +981,6 @@ class ControlView(BWExpander):
self.bw_add(self.__vbox)
class ControlNavigation(gtk.DrawingArea):
"""
"""
@@ -1047,12 +1001,12 @@ class ControlNavigation(gtk.DrawingArea):
self.__move_position = (0, 0)
self.__move_addition = [(-1, 0),
(-1,-1),
( 0,-1),
( 1,-1),
( 1, 0),
( 1, 1),
( 0, 1),
(-1, -1),
(0, -1),
(1, -1),
(1, 0),
(1, 1),
(0, 1),
(-1, 1)]
self.__move_factor = 1
@@ -1086,7 +1040,6 @@ class ControlNavigation(gtk.DrawingArea):
self.__rotate_node.set_coordinate(40, self.radialnet.get_rotation())
def key_press(self, widget, event):
"""
"""
@@ -1096,7 +1049,6 @@ class ControlNavigation(gtk.DrawingArea):
return True
def key_release(self, widget, event):
"""
"""
@@ -1106,13 +1058,11 @@ class ControlNavigation(gtk.DrawingArea):
return True
def enter_notify(self, widget, event):
"""
"""
return False
def leave_notify(self, widget, event):
"""
"""
@@ -1120,7 +1070,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def button_press(self, widget, event):
"""
Drawing callback
@@ -1159,7 +1108,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def button_release(self, widget, event):
"""
Drawing callback
@@ -1181,7 +1129,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def motion_notify(self, widget, event):
"""
Drawing callback
@@ -1213,7 +1160,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def expose(self, widget, event):
"""
Drawing callback
@@ -1231,7 +1177,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __draw_rotate_control(self):
"""
"""
@@ -1251,14 +1196,14 @@ class ControlNavigation(gtk.DrawingArea):
self.context.stroke()
# draw arc
self.context.set_dash([1,2])
self.context.set_dash([1, 2])
self.context.arc(xc, yc, 40, 0, 2 * math.pi)
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
self.context.stroke()
# draw node
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)
if self.__rotating == True:
@@ -1274,14 +1219,13 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __draw_move_control(self):
"""
"""
xc, yc = self.__center_of_widget
pc = PolarCoordinate()
self.context.set_dash([1,1])
self.context.set_dash([1, 1])
self.context.arc(xc, yc, 23, 0, 2 * math.pi)
self.context.set_source_rgb(0.0, 0.0, 0.0)
self.context.set_line_width(1)
@@ -1292,13 +1236,14 @@ class ControlNavigation(gtk.DrawingArea):
pc.set_coordinate(23, 45 * i)
x, y = pc.to_cartesian()
self.context.set_dash([1,1])
self.context.set_dash([1, 1])
self.context.move_to(xc, yc)
self.context.line_to(xc + x, yc - y)
self.context.stroke()
self.context.set_dash([1,0])
self.context.arc(xc + x, yc - y, self.__move_radius, 0, 2 * math.pi)
self.context.set_dash([1, 0])
self.context.arc(
xc + x, yc - y, self.__move_radius, 0, 2 * math.pi)
if i == self.__moving:
self.context.set_source_rgb(0.0, 0.0, 0.0)
@@ -1322,7 +1267,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __draw(self):
"""
Drawing method
@@ -1338,7 +1282,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __move_in_direction(self, direction):
"""
"""
@@ -1360,7 +1303,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __rotate_is_clicked(self, pointer):
"""
"""
@@ -1375,7 +1317,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __center_is_clicked(self, pointer):
"""
"""
@@ -1388,7 +1329,6 @@ class ControlNavigation(gtk.DrawingArea):
return False
def __move_is_clicked(self, pointer):
"""
"""
@@ -1409,5 +1349,3 @@ class ControlNavigation(gtk.DrawingArea):
return i
return None