Skip to content

Commit

Permalink
🎨 changes required by sonar linter
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Dec 28, 2023
1 parent f511ff7 commit 3991116
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/datasources/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def catch_validation_error():
NoDocumentVersions,
]
def process_erp_errors(erp_response):
if not 'error' in erp_response: return
if 'error' not in erp_response: return
erp_errors = {
excp.__name__: excp
for excp in expected_erp_exceptions
Expand Down
13 changes: 5 additions & 8 deletions backend/erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
# TODO; Use erppeek, connection pool management, transactions...

@decorator
def requiresToken(f, self, *args, **kwds):
try:
if not self._token:
self.token()
return f(self, *args, **kwds)
except Exception as e:
raise
def requires_token(f, self, *args, **kwds):
if not self._token:
self.token()
return f(self, *args, **kwds)

class ErpConnectionError(Exception): pass

Expand Down Expand Up @@ -56,7 +53,7 @@ def _post(self, endpoint, *args):
def token(self):
self._token = self._post('/common', 'token', self.db, self.user, self.password)

@requiresToken
@requires_token
def object_execute(self, *args):
return self._post('/object', 'execute', self.db, 'token', self._token, *args)

Expand Down

0 comments on commit 3991116

Please sign in to comment.