1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 19:59: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:
dmiller
2014-01-08 19:50:22 +00:00
parent 9210a7f1fa
commit 5c662fffdc
100 changed files with 2287 additions and 1814 deletions

View File

@@ -135,15 +135,12 @@ class Node(object):
self.__edges = []
"""List of edges to other nodes"""
def get_data(self):
return self.__data
def set_data(self, data):
self.__data = data
def get_edge(self, dest):
"""
Return the edge connecting to dest, or None if none
@@ -153,19 +150,16 @@ class Node(object):
return edge
return None
def get_edges(self):
"""
Return the list of edges
"""
return self.__edges
def add_edge(self, edge):
self.__edges.append(edge)
class Edge:
"""
"""
@@ -176,41 +170,34 @@ class Edge:
self.__nodes = nodes
self.__weights_mean = None
def get_nodes(self):
"""
"""
return self.__nodes
def get_weights(self):
"""
"""
return self.__weights
def set_weights(self, weights):
"""
"""
self.__weights = weights
self.__weights_mean = sum(self.__weights) / len(self.__weights)
def add_weight(self, weight):
"""
"""
self.__weights.append(weight)
self.__weights_mean = sum(self.__weights) / len(self.__weights)
def get_weights_mean(self):
"""
"""
return self.__weights_mean
class Graph:
"""
Network Graph class
@@ -227,19 +214,16 @@ class Graph:
self.__max_edge_mean_value = None
self.__min_edge_mean_value = None
def set_nodes(self, nodes):
"""
"""
self.__nodes = nodes
def get_nodes(self):
"""
"""
return self.__nodes
def get_number_of_nodes(self):
"""
Get the number of nodes in graph
@@ -248,7 +232,6 @@ class Graph:
"""
return len(self.__nodes)
def set_main_node(self, node):
"""
Set the main node
@@ -257,7 +240,6 @@ class Graph:
"""
self.__main_node = node
def get_main_node(self):
"""
Get the main node
@@ -266,7 +248,6 @@ class Graph:
"""
return self.__main_node
def set_connection(self, a, b, weight=None):
"""
Set node connections
@@ -287,12 +268,13 @@ class Graph:
edge.add_weight(weight)
mean_weight = edge.get_weights_mean()
if self.__min_edge_mean_value is None or mean_weight < self.__min_edge_mean_value:
if (self.__min_edge_mean_value is None or
mean_weight < self.__min_edge_mean_value):
self.__min_edge_mean_value = mean_weight
if self.__max_edge_mean_value is None or mean_weight > self.__max_edge_mean_value:
if (self.__max_edge_mean_value is None or
mean_weight > self.__max_edge_mean_value):
self.__max_edge_mean_value = mean_weight
def get_edges(self):
"""
An iterator that yields all edges
@@ -302,7 +284,6 @@ class Graph:
if edge.get_nodes()[0] == node:
yield edge
def get_node_connections(self, node):
"""
"""
@@ -319,16 +300,12 @@ class Graph:
return connections
def get_max_edge_mean_weight(self):
"""
"""
return self.__max_edge_mean_value
def get_min_edge_mean_weight(self):
"""
"""
return self.__min_edge_mean_value