mirror of
https://github.com/nmap/nmap.git
synced 2026-01-07 23:19:02 +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:
@@ -136,23 +136,24 @@ import gobject
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gtk.gtk_version
|
||||
assert gtk_version_major == 2
|
||||
|
||||
|
||||
def gtk_constant_name(group, value):
|
||||
"""
|
||||
Returns the (py)GTK+ name of a constant, given its group name
|
||||
"""
|
||||
group_response = { -1 : 'gtk.RESPONSE_NONE',
|
||||
-2 : 'gtk.RESPONSE_REJECT',
|
||||
-3 : 'gtk.RESPONSE_ACCEPT',
|
||||
-4 : 'gtk.RESPONSE_DELETE_EVENT',
|
||||
-5 : 'gtk.RESPONSE_OK',
|
||||
-6 : 'gtk.RESPONSE_CANCEL',
|
||||
-7 : 'gtk.RESPONSE_CLOSE',
|
||||
-8 : 'gtk.RESPONSE_YES',
|
||||
-9 : 'gtk.RESPONSE_NO',
|
||||
-10 : 'gtk.RESPONSE_APPLY',
|
||||
-11 : 'gtk.RESPONSE_HELP' }
|
||||
group_response = {-1: 'gtk.RESPONSE_NONE',
|
||||
-2: 'gtk.RESPONSE_REJECT',
|
||||
-3: 'gtk.RESPONSE_ACCEPT',
|
||||
-4: 'gtk.RESPONSE_DELETE_EVENT',
|
||||
-5: 'gtk.RESPONSE_OK',
|
||||
-6: 'gtk.RESPONSE_CANCEL',
|
||||
-7: 'gtk.RESPONSE_CLOSE',
|
||||
-8: 'gtk.RESPONSE_YES',
|
||||
-9: 'gtk.RESPONSE_NO',
|
||||
-10: 'gtk.RESPONSE_APPLY',
|
||||
-11: 'gtk.RESPONSE_HELP'}
|
||||
|
||||
groups = {'response' : group_response}
|
||||
groups = {'response': group_response}
|
||||
|
||||
return groups.get(group, {}).get(value, 'Error: constant value not found')
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGHBox', 'HIGVBox']
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGBox(gtk.Box):
|
||||
def _pack_noexpand_nofill(self, widget):
|
||||
self.pack_start(widget, expand=False, fill=False)
|
||||
@@ -137,6 +138,7 @@ class HIGBox(gtk.Box):
|
||||
def _pack_expand_fill(self, widget):
|
||||
self.pack_start(widget, expand=True, fill=True)
|
||||
|
||||
|
||||
class HIGHBox(gtk.HBox, HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.HBox.__init__(self, homogeneous, spacing)
|
||||
@@ -145,6 +147,7 @@ class HIGHBox(gtk.HBox, HIGBox):
|
||||
pack_label = HIGBox._pack_noexpand_nofill
|
||||
pack_entry = HIGBox._pack_expand_fill
|
||||
|
||||
|
||||
class HIGVBox(gtk.VBox, HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.VBox.__init__(self, homogeneous, spacing)
|
||||
@@ -152,6 +155,7 @@ class HIGVBox(gtk.VBox, HIGBox):
|
||||
# Packs a widget as a line, so it doesn't expand vertically
|
||||
pack_line = HIGBox._pack_noexpand_nofill
|
||||
|
||||
|
||||
class HIGSpacer(HIGHBox):
|
||||
def __init__(self, widget=None):
|
||||
HIGHBox.__init__(self)
|
||||
@@ -166,5 +170,6 @@ class HIGSpacer(HIGHBox):
|
||||
def get_child(self):
|
||||
return self.child
|
||||
|
||||
|
||||
def hig_box_space_holder():
|
||||
return gtk.Label(" ")
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGMixButton', 'HIGButton']
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGMixButton (gtk.HBox):
|
||||
def __init__(self, title, stock):
|
||||
gtk.HBox.__init__(self, False, 4)
|
||||
@@ -146,8 +147,9 @@ class HIGMixButton (gtk.HBox):
|
||||
self.pack_start(self.align)
|
||||
self.pack_start(self.hbox1)
|
||||
|
||||
|
||||
class HIGButton (gtk.Button):
|
||||
def __init__ (self, title="", stock=None):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
gtk.Button.__init__(self)
|
||||
content = HIGMixButton(title, stock)
|
||||
@@ -159,6 +161,7 @@ class HIGButton (gtk.Button):
|
||||
else:
|
||||
gtk.Button.__init__(self)
|
||||
|
||||
|
||||
class HIGToggleButton(gtk.ToggleButton):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
|
||||
@@ -132,6 +132,7 @@ import gtk
|
||||
|
||||
from gtkutils import gtk_version_minor
|
||||
|
||||
|
||||
class HIGDialog(gtk.Dialog):
|
||||
"""
|
||||
HIGFied Dialog
|
||||
@@ -142,6 +143,7 @@ class HIGDialog(gtk.Dialog):
|
||||
self.vbox.set_border_width(2)
|
||||
self.vbox.set_spacing(6)
|
||||
|
||||
|
||||
class HIGAlertDialog(gtk.MessageDialog):
|
||||
"""
|
||||
HIGfied Alert Dialog.
|
||||
|
||||
@@ -130,6 +130,7 @@ import gtk
|
||||
|
||||
HIGTextEntry = gtk.Entry
|
||||
|
||||
|
||||
class HIGPasswordEntry(HIGTextEntry):
|
||||
"""
|
||||
An entry that masks its text
|
||||
|
||||
@@ -132,6 +132,7 @@ import gtk
|
||||
|
||||
from higboxes import HIGHBox, hig_box_space_holder
|
||||
|
||||
|
||||
class HIGExpander(gtk.Expander):
|
||||
def __init__(self, label):
|
||||
gtk.Expander.__init__(self)
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGFrame']
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGFrame(gtk.Frame):
|
||||
"""
|
||||
Frame without border with bold label.
|
||||
|
||||
@@ -126,10 +126,13 @@ higwidgets/higlabels.py
|
||||
labels related classes
|
||||
"""
|
||||
|
||||
__all__ = ['HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel']
|
||||
__all__ = [
|
||||
'HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel'
|
||||
]
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGSectionLabel(gtk.Label):
|
||||
"""
|
||||
Bold label, used to define sections
|
||||
@@ -142,10 +145,11 @@ class HIGSectionLabel(gtk.Label):
|
||||
self.set_alignment(0, 0.50)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGHintSectionLabel(gtk.HBox, object):
|
||||
"""
|
||||
Bold label used to define sections, with a little icon that shows up a hint when mouse is
|
||||
over it.
|
||||
Bold label used to define sections, with a little icon that shows up a hint
|
||||
when mouse is over it.
|
||||
"""
|
||||
def __init__(self, text=None, hint=None):
|
||||
gtk.HBox.__init__(self)
|
||||
@@ -156,13 +160,15 @@ class HIGHintSectionLabel(gtk.HBox, object):
|
||||
self.pack_start(self.label, False, False)
|
||||
self.pack_start(self.hint, False, False, 5)
|
||||
|
||||
|
||||
class Hint(gtk.EventBox, object):
|
||||
def __init__(self, hint):
|
||||
gtk.EventBox.__init__(self)
|
||||
self.hint = hint
|
||||
|
||||
self.hint_image = gtk.Image()
|
||||
self.hint_image.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||
self.hint_image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||
|
||||
self.add(self.hint_image)
|
||||
|
||||
@@ -172,6 +178,7 @@ class Hint(gtk.EventBox, object):
|
||||
hint_window = HintWindow(self.hint)
|
||||
hint_window.show_all()
|
||||
|
||||
|
||||
class HintWindow(gtk.Window):
|
||||
def __init__(self, hint):
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
@@ -208,6 +215,7 @@ class HIGEntryLabel(gtk.Label):
|
||||
self.set_use_markup(True)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGDialogLabel(gtk.Label):
|
||||
"""
|
||||
Centered, line-wrappable label, usually used on dialogs.
|
||||
|
||||
@@ -135,6 +135,7 @@ from higlabels import HIGEntryLabel
|
||||
from higtables import HIGTable
|
||||
from higentries import HIGTextEntry, HIGPasswordEntry
|
||||
|
||||
|
||||
class HIGLoginDialog(HIGDialog):
|
||||
"""
|
||||
A dialog that asks for basic login information (username / password)
|
||||
|
||||
@@ -133,8 +133,11 @@ class HIGNotebook(gtk.Notebook):
|
||||
gtk.Notebook.__init__(self)
|
||||
self.popup_enable()
|
||||
|
||||
|
||||
class HIGClosableTabLabel(HIGHBox):
|
||||
__gsignals__ = { 'close-clicked' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()) }
|
||||
__gsignals__ = {
|
||||
'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, label_text=""):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
@@ -132,6 +132,7 @@ import gtk
|
||||
|
||||
from higboxes import HIGHBox
|
||||
|
||||
|
||||
class HIGLabeledProgressBar(HIGHBox):
|
||||
def __init__(self, label=None):
|
||||
HIGHBox.__init__(self)
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGScrolledWindow']
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGScrolledWindow(gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
|
||||
@@ -134,12 +134,14 @@ import gobject
|
||||
|
||||
from gtkutils import gobject_register
|
||||
|
||||
|
||||
class HIGSpinnerImages:
|
||||
def __init__(self):
|
||||
"""This class holds list of GDK Pixbuffers.
|
||||
|
||||
- static_pixbufs is used for multiple static pixbuffers
|
||||
- self.animated_pixbufs is used for the pixbuffers that make up the animation
|
||||
- self.animated_pixbufs is used for the pixbuffers that make up the
|
||||
animation
|
||||
"""
|
||||
|
||||
dprint('HIGSpinnerImages::__init__')
|
||||
@@ -182,7 +184,7 @@ class HIGSpinnerImages:
|
||||
|
||||
dprint('HIGSpinnerImages::set_rest_pixbuf')
|
||||
|
||||
if not self.static_pixbufs.has_key(name):
|
||||
if name not in self.static_pixbufs:
|
||||
raise StaticPixbufNotFound
|
||||
|
||||
# self.rest_pixbuf holds the *real* pixbuf, not it's name
|
||||
@@ -322,6 +324,7 @@ class HIGSpinnerCache:
|
||||
self.spinner_images.static_pixbufs[key_name].save(path_name,
|
||||
image_format)
|
||||
|
||||
|
||||
class HIGSpinner(gtk.EventBox):
|
||||
"""Simple spinner, such as the one found in webbrowsers and file managers.
|
||||
|
||||
@@ -331,8 +334,8 @@ class HIGSpinner(gtk.EventBox):
|
||||
* height, the height that will be set for the images
|
||||
"""
|
||||
|
||||
__gsignals__ = { 'expose-event' : 'override',
|
||||
'size-request' : 'override' }
|
||||
__gsignals__ = {'expose-event': 'override',
|
||||
'size-request': 'override'}
|
||||
|
||||
def __init__(self):
|
||||
gtk.EventBox.__init__(self)
|
||||
@@ -384,8 +387,8 @@ class HIGSpinner(gtk.EventBox):
|
||||
if self.timer_task == 0:
|
||||
self.current_pixbuf = self.cache.spinner_images.rest_pixbuf
|
||||
else:
|
||||
self.current_pixbuf = self.cache.spinner_images.animated_pixbufs\
|
||||
[self.animated_pixbuf_index]
|
||||
self.current_pixbuf = self.cache.spinner_images.animated_pixbufs[
|
||||
self.animated_pixbuf_index]
|
||||
|
||||
def start(self):
|
||||
"""Starts the animation"""
|
||||
@@ -401,11 +404,11 @@ class HIGSpinner(gtk.EventBox):
|
||||
self.timer_task = 0
|
||||
self.queue_draw()
|
||||
|
||||
|
||||
def stop(self):
|
||||
"""Stops the animation
|
||||
|
||||
Do the same stuff as pause, but returns the animation to the beggining."""
|
||||
Do the same stuff as pause, but returns the animation to the
|
||||
beginning."""
|
||||
self.pause()
|
||||
self.animated_pixbuf_index = 0
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ import gtk
|
||||
#from higlabels import *
|
||||
#from higentries import *
|
||||
|
||||
|
||||
class HIGTable(gtk.Table):
|
||||
"""
|
||||
A HIGFied table
|
||||
@@ -154,4 +155,4 @@ class HIGTable(gtk.Table):
|
||||
self.attach(widget, x0, x, y0, y, xoptions=gtk.FILL)
|
||||
|
||||
def attach_entry(self, widget, x0, x, y0, y):
|
||||
self.attach(widget, x0, x, y0, y, xoptions=gtk.FILL|gtk.EXPAND)
|
||||
self.attach(widget, x0, x, y0, y, xoptions=gtk.FILL | gtk.EXPAND)
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGTextView']
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGTextView(gtk.TextView):
|
||||
def __init__(self, text=''):
|
||||
gtk.TextView.__init__(self)
|
||||
|
||||
@@ -128,6 +128,7 @@ higwidgets/higwindows.py
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class HIGWindow(gtk.Window):
|
||||
"""HIGFied Window"""
|
||||
def __init__(self, type=gtk.WINDOW_TOPLEVEL):
|
||||
|
||||
@@ -130,6 +130,7 @@ __all__ = ['HIGSpinner']
|
||||
|
||||
import gobject
|
||||
|
||||
|
||||
def gobject_register(klass):
|
||||
if gtk_version_minor < 8:
|
||||
gobject.type_register(klass)
|
||||
|
||||
Reference in New Issue
Block a user