Skip to content

Commit a405f2a

Browse files
authored
Merge pull request #31 from cmeissner/code_style_fixes
fix issues from codacy report
2 parents cfac7d2 + 4a5a9e3 commit a405f2a

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

phpypam/core/api.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Api(object):
2020
different actions again to `create`, `update` and `delete` entities.
2121
It also provides functions with informational character only.
2222
"""
23-
2423
def __init__(self, url, app_id, username=None, password=None, token=None, encryption=False, timeout=None, ssl_verify=True, user_agent=None):
2524

2625
""" contructor method
@@ -45,7 +44,6 @@ def __init__(self, url, app_id, username=None, password=None, token=None, encryp
4544
:param user_agent: With this parameter you can define a own user agent header string., defaults to None
4645
:type user_agent: str, optional
4746
"""
48-
4947
self._api_url = url
5048
self._api_appid = app_id
5149
self._api_username = username
@@ -89,7 +87,6 @@ def _query(self, path='user', headers=None, method=GET, data=None, params=None,
8987
:return: If query returns any data it returns this dict or list else it returns last exit status
9088
:rtype: Union[bool, dict, list]
9189
"""
92-
9390
_api_path = path
9491
_api_headers = headers or {}
9592
_method = method
@@ -124,10 +121,7 @@ def _query(self, path='user', headers=None, method=GET, data=None, params=None,
124121
return result['data']
125122

126123
def _login(self):
127-
128-
""" Login method
129-
"""
130-
124+
""" Login method """
131125
_auth = HTTPBasicAuth(self._api_username, self._api_password)
132126
resp = self._query(method=POST, auth=_auth)
133127

@@ -139,7 +133,6 @@ def get_token(self):
139133
:return: Returns the api token from the last successful login.
140134
:rtype: str
141135
"""
142-
143136
return self._api_token
144137

145138
def get_entity(self, controller, controller_path=None, params=None):
@@ -155,7 +148,6 @@ def get_entity(self, controller, controller_path=None, params=None):
155148
:return: Result of the query. It can be either a 'list' or 'dict'.
156149
:rtype: Union[dict, list]
157150
"""
158-
159151
_path = controller
160152
_controller_path = controller_path
161153
_params = params
@@ -180,7 +172,6 @@ def create_entity(self, controller, controller_path=None, data=None, params=None
180172
:return: Returns the newly created entity.
181173
:rtype: Union[dict, list]
182174
"""
183-
184175
_path = controller
185176
_controller_path = controller_path
186177
_params = params
@@ -203,7 +194,6 @@ def delete_entity(self, controller, controller_path, params=None):
203194
:return: Returns True if entity was deleted successfully or either 'dict' or 'list' of entities to work on.
204195
:rtype: Union[book, dict, list]
205196
"""
206-
207197
_path = '{}/{}'.format(controller, controller_path)
208198
_params = params
209199

@@ -224,7 +214,6 @@ def update_entity(self, controller, controller_path=None, data=None, params=None
224214
:return: Returns either a 'dict' or 'list' of the changed entity
225215
:rtype: Union[dict, list]
226216
"""
227-
228217
_path = controller
229218
_controller_path = controller_path
230219
_params = params
@@ -241,7 +230,6 @@ def controllers(self):
241230
:return: Returns a tuple of controller paths.
242231
:rtype: tuple
243232
"""
244-
245233
result = self._query(token=self._api_token, method=OPTIONS, path='/')
246234

247235
controllers = ({re.sub(r'^/api/' + self._api_appid + '/(.+)/$', r'\1', v) for ctrl in result['controllers'] for (k, v) in ctrl.items() if k == 'href'})

phpypam/core/exceptions.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,32 @@ def __init__(self, *args, code=None, message=None):
4444

4545

4646
class PHPyPAMInvalidCredentials(Exception):
47+
4748
""" Exception PHPyPAMInvalidCredentials, children of :class:`Exception`.
4849
This Exception is raised if there are any issues with the authentication against phpIPAM api.
4950
"""
5051
def __init__(self, *args, **kwargs):
51-
52-
""" constructor method
53-
"""
52+
""" constructor method """
5453
super(PHPyPAMInvalidCredentials, self).__init__(*args, **kwargs)
5554

5655

5756
class PHPyPAMEntityNotFoundException(Exception):
57+
5858
""" Exception PHPyPAMEntityNotFoundException, children of :class:`Exception`.
5959
This Exception is raised if an entity was not found.
6060
"""
6161
def __init__(self, *args, **kwargs):
62-
63-
""" constructor method
64-
"""
62+
""" constructor method """
6563
super(PHPyPAMEntityNotFoundException, self).__init__(*args, **kwargs)
6664

6765

6866
class PHPyPAMInvalidSyntax(Exception):
67+
6968
""" Exception PHPyPAMInvalidSyntax, children of :class:`Exception`.
7069
This Exception is raised if there are any issues with syntax of request against phpIPAM api.
7170
"""
7271
def __init__(self, *args, **kwargs):
73-
74-
""" constructor method
75-
"""
72+
""" constructor method """
7673
self._message = kwargs.pop('message', '')
7774

7875
super(PHPyPAMInvalidSyntax, self).__init__(self._message, *args, **kwargs)

0 commit comments

Comments
 (0)