1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

Address review comments

Added a missing comma to the category_map literal
Added parens around an index that does math beforehand
Clarified HTTP/JSON error CredentialsError
This commit is contained in:
A_D 2020-07-08 18:05:43 +02:00
parent dcb9853b68
commit 2890d33d03
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4

View File

@ -52,7 +52,7 @@ category_map = {
'Narcotics' : 'Legal Drugs',
'Slaves' : 'Slavery',
'Waste ' : 'Waste',
'NonMarketable' : False # Don't appear in the in-game market so don't report
'NonMarketable' : False, # Don't appear in the in-game market so don't report
}
commodity_map = {}
@ -231,7 +231,7 @@ class Auth(object):
print('Auth\tMalformed response {!r}'.format(payload))
raise CredentialsError('malformed payload') # Not well formed
data = urllib.parse.parse_qs(payload[payload.index('?') + 1:])
data = urllib.parse.parse_qs(payload[(payload.index('?') + 1):])
if not self.state or not data.get('state') or data['state'][0] != self.state:
print('Auth\tUnexpected response {!r}'.format(payload))
raise CredentialsError('Unexpected response from authorization {!r}'.format(payload)) # Unexpected reply
@ -311,7 +311,7 @@ class Session(object):
def login(self, cmdr=None, is_beta=None):
# Returns True if login succeeded, False if re-authorization initiated.
if not CLIENT_ID:
raise CredentialsError('cannot login without a valid client ID')
raise CredentialsError('cannot login without a valid Client ID')
if not cmdr or is_beta is None:
# Use existing credentials
@ -418,7 +418,7 @@ class Session(object):
else:
self.retrying = False
raise CredentialsError('Invalid JSON or HTTP error') from e
raise CredentialsError('HTTP error or invalid JSON') from e
self.retrying = False
if 'timestamp' not in data: