mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11: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:
@@ -134,6 +134,7 @@ from zenmapGUI.higwidgets.higtables import HIGTable
|
||||
from zenmapGUI.higwidgets.higlabels import HIGEntryLabel
|
||||
from zenmapGUI.higwidgets.higbuttons import HIGButton, HIGToggleButton
|
||||
|
||||
|
||||
class NmapOutputProperties(HIGDialog):
|
||||
def __init__(self, nmap_output_view):
|
||||
HIGDialog.__init__(self, _("Nmap Output Properties"),
|
||||
@@ -164,10 +165,14 @@ class NmapOutputProperties(HIGDialog):
|
||||
#############
|
||||
# Properties:
|
||||
self.property_names = {"details": [_("details"), "MAC Address:"],
|
||||
"port_list": [_("port listing title"), "PORT STATE SERVICE"],
|
||||
"open_port": [_("open port"), "22/tcp open ssh"],
|
||||
"closed_port": [_("closed port"), "70/tcp closed gopher"],
|
||||
"filtered_port": [_("filtered port"), "80/tcp filtered http"],
|
||||
"port_list": [_("port listing title"),
|
||||
"PORT STATE SERVICE"],
|
||||
"open_port": [_("open port"),
|
||||
"22/tcp open ssh"],
|
||||
"closed_port": [_("closed port"),
|
||||
"70/tcp closed gopher"],
|
||||
"filtered_port": [_("filtered port"),
|
||||
"80/tcp filtered http"],
|
||||
"date": [_("date"), "2006-05-26 11:14 BRT"],
|
||||
"hostname": [_("hostname"), "scanme.nmap.org"],
|
||||
"ip": [_("ip"), "127.0.0.1"]}
|
||||
@@ -182,18 +187,23 @@ class NmapOutputProperties(HIGDialog):
|
||||
self.property_names[p].append(gtk.gdk.Color(*settings[4]))
|
||||
self.property_names[p].append(settings[5])
|
||||
|
||||
# Creating properties and related widgets and attaching it to main table
|
||||
# Creating properties and related widgets and attaching it to main
|
||||
# table
|
||||
y1 = 0
|
||||
y2 = 1
|
||||
for p in self.property_names:
|
||||
hp = HighlightProperty(p, self.property_names[p])
|
||||
self.highlight_main_table.attach(hp.property_name_label, 0, 1, y1, y2)
|
||||
self.highlight_main_table.attach(
|
||||
hp.property_name_label, 0, 1, y1, y2)
|
||||
self.highlight_main_table.attach(hp.example_label, 1, 2, y1, y2)
|
||||
self.highlight_main_table.attach(hp.bold_tg_button, 2, 3, y1, y2)
|
||||
self.highlight_main_table.attach(hp.italic_tg_button, 3, 4, y1, y2)
|
||||
self.highlight_main_table.attach(hp.underline_tg_button, 4, 5, y1, y2)
|
||||
self.highlight_main_table.attach(hp.text_color_button, 5, 6, y1, y2)
|
||||
self.highlight_main_table.attach(hp.highlight_color_button, 6, 7, y1, y2)
|
||||
self.highlight_main_table.attach(
|
||||
hp.underline_tg_button, 4, 5, y1, y2)
|
||||
self.highlight_main_table.attach(
|
||||
hp.text_color_button, 5, 6, y1, y2)
|
||||
self.highlight_main_table.attach(
|
||||
hp.highlight_color_button, 6, 7, y1, y2)
|
||||
|
||||
# Setting example styles and colors
|
||||
hp.update_example()
|
||||
@@ -203,13 +213,13 @@ class NmapOutputProperties(HIGDialog):
|
||||
y1 += 1
|
||||
y2 += 1
|
||||
|
||||
|
||||
# Packing main table into main vbox
|
||||
self.highlight_main_vbox.pack_start(self.highlight_main_table)
|
||||
|
||||
# Adding color tab
|
||||
self.properties_notebook.append_page(self.highlight_main_vbox,
|
||||
gtk.Label(_("Highlight definitions")))
|
||||
self.properties_notebook.append_page(
|
||||
self.highlight_main_vbox,
|
||||
gtk.Label(_("Highlight definitions")))
|
||||
|
||||
|
||||
class HighlightProperty(object):
|
||||
@@ -235,8 +245,10 @@ class HighlightProperty(object):
|
||||
self.bold_tg_button = HIGToggleButton("", gtk.STOCK_BOLD)
|
||||
self.italic_tg_button = HIGToggleButton("", gtk.STOCK_ITALIC)
|
||||
self.underline_tg_button = HIGToggleButton("", gtk.STOCK_UNDERLINE)
|
||||
self.text_color_button = HIGButton(_("Text"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
self.highlight_color_button = HIGButton(_("Highlight"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
self.text_color_button = HIGButton(
|
||||
_("Text"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
self.highlight_color_button = HIGButton(
|
||||
_("Highlight"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
|
||||
def __connect_buttons(self):
|
||||
self.bold_tg_button.connect("toggled", self.update_example)
|
||||
@@ -244,20 +256,23 @@ class HighlightProperty(object):
|
||||
self.underline_tg_button.connect("toggled", self.update_example)
|
||||
|
||||
self.text_color_button.connect("clicked", self.text_color_dialog)
|
||||
self.highlight_color_button.connect("clicked", self.highlight_color_dialog)
|
||||
|
||||
self.highlight_color_button.connect(
|
||||
"clicked", self.highlight_color_dialog)
|
||||
|
||||
####################################
|
||||
# Text color dialog
|
||||
|
||||
def text_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog("%s %s" % (self.label, _("text color")))
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
"%s %s" % (self.label, _("text color")))
|
||||
color_dialog.colorsel.set_current_color(self.text_color)
|
||||
|
||||
color_dialog.ok_button.connect("clicked", self.text_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect("clicked",
|
||||
self.text_color_dialog_cancel, color_dialog)
|
||||
color_dialog.connect("delete-event", self.text_color_dialog_close, color_dialog)
|
||||
color_dialog.ok_button.connect(
|
||||
"clicked", self.text_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
"clicked", self.text_color_dialog_cancel, color_dialog)
|
||||
color_dialog.connect(
|
||||
"delete-event", self.text_color_dialog_close, color_dialog)
|
||||
|
||||
color_dialog.run()
|
||||
|
||||
@@ -272,18 +287,21 @@ class HighlightProperty(object):
|
||||
def text_color_dialog_close(self, widget, extra, color_dialog):
|
||||
color_dialog.destroy()
|
||||
|
||||
|
||||
#########################################
|
||||
# Highlight color dialog
|
||||
def highlight_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog("%s %s" % (self.property_name,
|
||||
_("highlight color")))
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
"%s %s" % (self.property_name, _("highlight color")))
|
||||
color_dialog.colorsel.set_current_color(self.highlight_color)
|
||||
|
||||
color_dialog.ok_button.connect("clicked", self.highlight_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect("clicked", self.highlight_color_dialog_cancel,
|
||||
color_dialog.ok_button.connect(
|
||||
"clicked", self.highlight_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
"clicked", self.highlight_color_dialog_cancel,
|
||||
color_dialog)
|
||||
color_dialog.connect("delete-event", self.highlight_color_dialog_close, color_dialog)
|
||||
color_dialog.connect(
|
||||
"delete-event", self.highlight_color_dialog_close,
|
||||
color_dialog)
|
||||
|
||||
color_dialog.run()
|
||||
|
||||
@@ -304,8 +322,9 @@ class HighlightProperty(object):
|
||||
|
||||
attributes = pango.AttrList()
|
||||
|
||||
attributes.insert(pango.AttrForeground(self.text_color.red, self.text_color.green,
|
||||
self.text_color.blue, start, end))
|
||||
attributes.insert(
|
||||
pango.AttrForeground(self.text_color.red,
|
||||
self.text_color.green, self.text_color.blue, start, end))
|
||||
attributes.insert(pango.AttrBackground(self.highlight_color.red,
|
||||
self.highlight_color.green,
|
||||
self.highlight_color.blue,
|
||||
@@ -315,7 +334,8 @@ class HighlightProperty(object):
|
||||
if self.bold_tg_button.get_active():
|
||||
attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, start, end))
|
||||
else:
|
||||
attributes.insert(pango.AttrWeight(pango.WEIGHT_NORMAL, start, end))
|
||||
attributes.insert(
|
||||
pango.AttrWeight(pango.WEIGHT_NORMAL, start, end))
|
||||
|
||||
# Italic verification
|
||||
if self.italic_tg_button.get_active():
|
||||
@@ -325,13 +345,14 @@ class HighlightProperty(object):
|
||||
|
||||
# Underline verification
|
||||
if self.underline_tg_button.get_active():
|
||||
attributes.insert(pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end))
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end))
|
||||
else:
|
||||
attributes.insert(pango.AttrUnderline(pango.UNDERLINE_NONE, start, end))
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_NONE, start, end))
|
||||
|
||||
self.example_label.set_attributes(attributes)
|
||||
|
||||
|
||||
def show_bold(self, widget):
|
||||
self.example_label.set_markup("<>")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user