mirror of
https://github.com/nmap/nmap.git
synced 2025-12-14 03:39: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:
@@ -133,8 +133,8 @@ TYPES = ((_("By extension"), None, None),
|
||||
(_("PNG"), RadialNet.FILE_TYPE_PNG, ".png"),
|
||||
(_("PostScript"), RadialNet.FILE_TYPE_PS, ".ps"),
|
||||
(_("SVG"), RadialNet.FILE_TYPE_SVG, ".svg"))
|
||||
# Build a reverse index of extensions to file types, for the "By extension" file
|
||||
# type.
|
||||
# Build a reverse index of extensions to file types, for the "By extension"
|
||||
# file type.
|
||||
EXTENSIONS = {}
|
||||
for type in TYPES:
|
||||
if type[2] is not None:
|
||||
@@ -181,7 +181,8 @@ class SaveDialog(zenmapGUI.FileChoosers.UnicodeFileChooserDialog):
|
||||
self.set_current_folder(dir)
|
||||
|
||||
# Find the recommended extension.
|
||||
new_ext = self.__combo.get_model().get_value(self.__combo.get_active_iter(), 2)
|
||||
new_ext = self.__combo.get_model().get_value(
|
||||
self.__combo.get_active_iter(), 2)
|
||||
if new_ext is not None:
|
||||
# Change the filename to use the recommended extension.
|
||||
root, ext = os.path.splitext(basename)
|
||||
@@ -197,15 +198,17 @@ class SaveDialog(zenmapGUI.FileChoosers.UnicodeFileChooserDialog):
|
||||
if ext == "":
|
||||
filename = self.get_filename() or ""
|
||||
dir, basename = os.path.split(filename)
|
||||
alert = HIGAlertDialog(message_format=_("No filename extension"),
|
||||
secondary_text=_("""\
|
||||
The filename "%s" does not have an extension, and no specific file type was chosen.
|
||||
Enter a known extension or select the file type from the list.\
|
||||
""" % basename))
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("No filename extension"),
|
||||
secondary_text=_("""\
|
||||
The filename "%s" does not have an extension, \
|
||||
and no specific file type was chosen.
|
||||
Enter a known extension or select the file type from the list.""" % basename))
|
||||
|
||||
else:
|
||||
alert = HIGAlertDialog(message_format=_("Unknown filename extension"),
|
||||
secondary_text=_("""\
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Unknown filename extension"),
|
||||
secondary_text=_("""\
|
||||
There is no file type known for the filename extension "%s".
|
||||
Enter a known extension or select the file type from the list.\
|
||||
""") % self.__get_extension())
|
||||
@@ -218,7 +221,8 @@ Enter a known extension or select the file type from the list.\
|
||||
return os.path.splitext(self.get_filename())[1]
|
||||
|
||||
def get_filetype(self):
|
||||
filetype = self.__combo.get_model().get_value(self.__combo.get_active_iter(), 1)
|
||||
filetype = self.__combo.get_model().get_value(
|
||||
self.__combo.get_active_iter(), 1)
|
||||
if filetype is None:
|
||||
# Guess based on extension.
|
||||
return EXTENSIONS.get(self.__get_extension())
|
||||
|
||||
Reference in New Issue
Block a user