mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 21:21:31 +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:
@@ -124,14 +124,12 @@ import xml.sax.saxutils
|
||||
from xml.sax.xmlreader import AttributesImpl as Attributes
|
||||
|
||||
|
||||
|
||||
def convert_to_utf8(text):
|
||||
"""
|
||||
"""
|
||||
return text.encode('utf8', 'replace')
|
||||
|
||||
|
||||
|
||||
class XMLNode:
|
||||
"""
|
||||
"""
|
||||
@@ -143,70 +141,59 @@ class XMLNode:
|
||||
self.__attrs = dict()
|
||||
self.__children = []
|
||||
|
||||
|
||||
def set_text(self, text):
|
||||
"""
|
||||
"""
|
||||
self.__text = text
|
||||
|
||||
|
||||
def get_text(self):
|
||||
"""
|
||||
"""
|
||||
return self.__text
|
||||
|
||||
|
||||
def set_name(self, name):
|
||||
"""
|
||||
"""
|
||||
self.__name = name
|
||||
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
"""
|
||||
return self.__name
|
||||
|
||||
|
||||
def add_attr(self, key, value):
|
||||
"""
|
||||
"""
|
||||
self.__attrs[key] = value
|
||||
|
||||
|
||||
def add_child(self, child):
|
||||
"""
|
||||
"""
|
||||
self.__children.append(child)
|
||||
|
||||
|
||||
def get_keys(self):
|
||||
"""
|
||||
"""
|
||||
return self.__attrs.keys()
|
||||
|
||||
|
||||
def get_attr(self, attr):
|
||||
"""
|
||||
"""
|
||||
if self.__attrs.has_key(attr):
|
||||
if attr in self.__attrs:
|
||||
return self.__attrs[attr]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_attrs(self):
|
||||
"""
|
||||
"""
|
||||
return self.__attrs
|
||||
|
||||
|
||||
def get_children(self):
|
||||
"""
|
||||
"""
|
||||
return self.__children
|
||||
|
||||
|
||||
def query_children(self, name, attr, value, first=False, deep=False):
|
||||
"""
|
||||
"""
|
||||
@@ -216,7 +203,7 @@ class XMLNode:
|
||||
|
||||
if child.get_name() == name:
|
||||
|
||||
if child.get_attrs().has_key(attr):
|
||||
if attr in child.get_attrs():
|
||||
|
||||
c_value = child.get_attr(attr)
|
||||
|
||||
@@ -243,7 +230,6 @@ class XMLNode:
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def search_children(self, name, first=False, deep=False):
|
||||
"""
|
||||
"""
|
||||
@@ -276,7 +262,6 @@ class XMLNode:
|
||||
return result
|
||||
|
||||
|
||||
|
||||
class XMLWriter(xml.sax.saxutils.XMLGenerator):
|
||||
"""
|
||||
"""
|
||||
@@ -287,13 +272,11 @@ class XMLWriter(xml.sax.saxutils.XMLGenerator):
|
||||
|
||||
self.__root = root
|
||||
|
||||
|
||||
def set_root(self, root):
|
||||
"""
|
||||
"""
|
||||
self.__root = root
|
||||
|
||||
|
||||
def write(self):
|
||||
"""
|
||||
"""
|
||||
@@ -301,7 +284,6 @@ class XMLWriter(xml.sax.saxutils.XMLGenerator):
|
||||
self.write_xml_node([self.__root])
|
||||
self.endDocument()
|
||||
|
||||
|
||||
def write_xml_node(self, root):
|
||||
"""
|
||||
"""
|
||||
@@ -317,7 +299,6 @@ class XMLWriter(xml.sax.saxutils.XMLGenerator):
|
||||
self.endElement(child.get_name())
|
||||
|
||||
|
||||
|
||||
class XMLReader(xml.sax.ContentHandler):
|
||||
"""
|
||||
"""
|
||||
@@ -330,41 +311,35 @@ class XMLReader(xml.sax.ContentHandler):
|
||||
self.__file = file
|
||||
self.__root = None
|
||||
|
||||
self.__parser = xml.sax.make_parser();
|
||||
self.__parser.setContentHandler(self);
|
||||
|
||||
self.__parser = xml.sax.make_parser()
|
||||
self.__parser.setContentHandler(self)
|
||||
|
||||
def set_file(self, file, root):
|
||||
"""
|
||||
"""
|
||||
self.__file = file
|
||||
|
||||
|
||||
def get_file(self):
|
||||
"""
|
||||
"""
|
||||
return self.__file
|
||||
|
||||
|
||||
def get_root(self):
|
||||
"""
|
||||
"""
|
||||
return self.__root
|
||||
|
||||
|
||||
def parse(self):
|
||||
"""
|
||||
"""
|
||||
if self.__file != None:
|
||||
self.__parser.parse(self.__file)
|
||||
|
||||
|
||||
def startDocument(self):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
"""
|
||||
"""
|
||||
@@ -384,7 +359,6 @@ class XMLReader(xml.sax.ContentHandler):
|
||||
|
||||
self.__status.append(node)
|
||||
|
||||
|
||||
def endElement(self, name):
|
||||
"""
|
||||
"""
|
||||
@@ -393,20 +367,17 @@ class XMLReader(xml.sax.ContentHandler):
|
||||
self.__text = ""
|
||||
self.__status.pop()
|
||||
|
||||
|
||||
def endDocument(self):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def characters(self, text):
|
||||
"""
|
||||
"""
|
||||
self.__text += text
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
import sys
|
||||
|
||||
Reference in New Issue
Block a user