mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 22:21:29 +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:
@@ -171,13 +171,18 @@ if pixmap_path:
|
||||
# Try again.
|
||||
pass
|
||||
else:
|
||||
log.warn('Could not find the icon for %s at any of (%s) in %s' % (icon_name, ', '.join(get_pixmap_file_names(icon_name, size)), pixmap_path))
|
||||
log.warn('Could not find the icon for %s at '
|
||||
'any of (%s) in %s' % (
|
||||
icon_name,
|
||||
', '.join(get_pixmap_file_names(icon_name, size)),
|
||||
pixmap_path))
|
||||
continue
|
||||
iconset = gtk.IconSet(pixbuf)
|
||||
iconfactory.add(key, iconset)
|
||||
log.debug('Register %s icon name for file %s' % (key, file_path))
|
||||
iconfactory.add_default()
|
||||
|
||||
|
||||
def get_os_icon(host):
|
||||
osmatch = host.get_best_osmatch()
|
||||
if osmatch and osmatch['osclasses']:
|
||||
@@ -190,6 +195,7 @@ def get_os_icon(host):
|
||||
else:
|
||||
return get_os(None, None, 'icon')
|
||||
|
||||
|
||||
def get_os_logo(host):
|
||||
osmatch = host.get_best_osmatch()
|
||||
if osmatch and osmatch['osclasses']:
|
||||
@@ -202,51 +208,53 @@ def get_os_logo(host):
|
||||
else:
|
||||
return get_os(None, None, 'logo')
|
||||
|
||||
|
||||
def get_os(osfamily, osmatch, type):
|
||||
if osfamily:
|
||||
if osfamily == 'Linux':
|
||||
if re.findall("ubuntu", osmatch.lower()):
|
||||
# Ubuntu icon
|
||||
return 'ubuntu_%s'%type
|
||||
return 'ubuntu_%s' % type
|
||||
elif re.findall("red hat", osmatch.lower()):
|
||||
# RedHat icon
|
||||
return 'redhat_%s'%type
|
||||
return 'redhat_%s' % type
|
||||
else:
|
||||
# Generic Linux icon
|
||||
return 'linux_%s'%type
|
||||
return 'linux_%s' % type
|
||||
elif osfamily == 'Windows':
|
||||
# Windows icon
|
||||
return 'win_%s'%type
|
||||
return 'win_%s' % type
|
||||
elif osfamily == 'OpenBSD':
|
||||
# OpenBSD icon
|
||||
return 'openbsd_%s'%type
|
||||
return 'openbsd_%s' % type
|
||||
elif osfamily == 'FreeBSD':
|
||||
# FreeBSD icon
|
||||
return 'freebsd_%s'%type
|
||||
return 'freebsd_%s' % type
|
||||
elif osfamily == 'NetBSD':
|
||||
# NetBSD icon
|
||||
return 'default_%s'%type
|
||||
return 'default_%s' % type
|
||||
elif osfamily == 'Solaris':
|
||||
# Solaris icon
|
||||
return 'solaris_%s'%type
|
||||
return 'solaris_%s' % type
|
||||
elif osfamily == 'OpenSolaris':
|
||||
# OpenSolaris icon
|
||||
return 'solaris_%s'%type
|
||||
return 'solaris_%s' % type
|
||||
elif osfamily == 'IRIX':
|
||||
# Irix icon
|
||||
return 'irix_%s'%type
|
||||
return 'irix_%s' % type
|
||||
elif osfamily == 'Mac OS X':
|
||||
# Mac OS X icon
|
||||
return 'macosx_%s'%type
|
||||
return 'macosx_%s' % type
|
||||
elif osfamily == 'Mac OS':
|
||||
# Mac OS icon
|
||||
return 'macosx_%s'%type
|
||||
return 'macosx_%s' % type
|
||||
else:
|
||||
# Default OS icon
|
||||
return 'default_%s'%type
|
||||
return 'default_%s' % type
|
||||
else:
|
||||
# Unknown OS icon
|
||||
return 'unknown_%s'%type
|
||||
return 'unknown_%s' % type
|
||||
|
||||
|
||||
def get_vulnerability_logo(open_ports):
|
||||
open_ports = int(open_ports)
|
||||
|
||||
Reference in New Issue
Block a user