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:
@@ -141,31 +141,26 @@ class PolarCoordinate:
|
||||
self.__t = t
|
||||
"""Angle (theta) of polar coordinate in radians"""
|
||||
|
||||
|
||||
def get_theta(self):
|
||||
"""
|
||||
"""
|
||||
return math.degrees(self.__t)
|
||||
|
||||
|
||||
def get_radius(self):
|
||||
"""
|
||||
"""
|
||||
return self.__r
|
||||
|
||||
|
||||
def set_theta(self, t):
|
||||
"""
|
||||
"""
|
||||
self.__t = math.radians(t)
|
||||
|
||||
|
||||
def set_radius(self, r):
|
||||
"""
|
||||
"""
|
||||
self.__r = r
|
||||
|
||||
|
||||
def get_coordinate(self):
|
||||
"""
|
||||
Set polar coordinate
|
||||
@@ -174,7 +169,6 @@ class PolarCoordinate:
|
||||
"""
|
||||
return (self.__r, math.degrees(self.__t))
|
||||
|
||||
|
||||
def set_coordinate(self, r, t):
|
||||
"""
|
||||
Set polar coordinate
|
||||
@@ -186,7 +180,6 @@ class PolarCoordinate:
|
||||
self.__r = r
|
||||
self.__t = math.radians(t)
|
||||
|
||||
|
||||
def to_cartesian(self):
|
||||
"""
|
||||
Convert polar in cartesian coordinate
|
||||
@@ -199,12 +192,10 @@ class PolarCoordinate:
|
||||
return (x, y)
|
||||
|
||||
|
||||
|
||||
class CartesianCoordinate:
|
||||
"""
|
||||
Class to implement a cartesian coordinate object
|
||||
"""
|
||||
|
||||
def __init__(self, x=0, y=0):
|
||||
"""
|
||||
Constructor method of CartesianCoordinate class
|
||||
@@ -218,7 +209,6 @@ class CartesianCoordinate:
|
||||
self.__y = y
|
||||
"""Y component of cartesian coordinate"""
|
||||
|
||||
|
||||
def get_coordinate(self):
|
||||
"""
|
||||
Get cartesian coordinate
|
||||
@@ -227,7 +217,6 @@ class CartesianCoordinate:
|
||||
"""
|
||||
return (self.__x, self.__y)
|
||||
|
||||
|
||||
def set_coordinate(self, x, y):
|
||||
"""
|
||||
Set cartesian coordinate
|
||||
@@ -239,25 +228,24 @@ class CartesianCoordinate:
|
||||
self.__x = x
|
||||
self.__y = y
|
||||
|
||||
|
||||
def to_polar(self):
|
||||
"""
|
||||
Convert cartesian in polar coordinate
|
||||
@rtype: tuple
|
||||
@return: polar coordinates (r, t)
|
||||
"""
|
||||
r = math.sqrt(self.__x**2 + self.__y**2)
|
||||
r = math.sqrt(self.__x ** 2 + self.__y ** 2)
|
||||
|
||||
if self.__x > 0:
|
||||
|
||||
if self.__y >= 0:
|
||||
t = math.atan( self.__y / self.__x )
|
||||
t = math.atan(self.__y / self.__x)
|
||||
|
||||
else:
|
||||
t = math.atan( self.__y / self.__x ) + 2 * math.pi
|
||||
t = math.atan(self.__y / self.__x) + 2 * math.pi
|
||||
|
||||
elif self.__x < 0:
|
||||
t = math.atan( self.__y / self.__x ) + math.pi
|
||||
t = math.atan(self.__y / self.__x) + math.pi
|
||||
|
||||
elif self.__x == 0:
|
||||
|
||||
@@ -273,12 +261,11 @@ class CartesianCoordinate:
|
||||
return (r, t)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Testing application
|
||||
|
||||
polar = PolarCoordinate(1, math.pi)
|
||||
polar = PolarCoordinate(1, math.pi)
|
||||
cartesian = CartesianCoordinate(-1, 0)
|
||||
|
||||
print polar.to_cartesian()
|
||||
|
||||
Reference in New Issue
Block a user