* The companion Session.query is called for *all* CAPI endpoints and
only the /profile one will return lastStartport data, which is where
ships/modules are if present, so only do these checks if we see
lastStarport.
Currently it is simply a dict subclass that does some of the cleanup
required to make everything happy. In future it will be changed to be a
NamedTuple or similar that can be typed
I was testing the new Steam or Epic CAPI auth. My EGS account hasn't
yet been used, so has no commander attached. EDMC thinks the auth has
succeeded in this case, but hitting 'Update' causes it to error because
the returned data is empty.
So, add some checks for lack of 'commander' key and a specific message
"CAPI: No commander data returned" for status line.
Without this there's a KeyError exception thrown, causing the status
line to just get 'commander' in it, which isn't helpful.
Else at least one caller to .station() blows up when it can't find the
commander data.
The call has to be to .station() so as to populate the market/shipyard
added dictionaries.
* Correct use of error[0] to just error.
* We don't want methods not referencing self to be static in this case,
so annotate them.
* Take suggestion of "if v == []:" equivalent to "if not v:".
* Preserve CAPIData typing throughout filter_ship().
* CAPI Data really is just a Dict. Define a custom type so it could
easily be a class in future with minimal edits.
* Auth.refresh() *can* also return a str (Access Token).
* Catch specific (but still quite loose) exceptions in Auth.refresh().
* Set self.server in Session.__init__.
* Remove some extraneous () on conditionals.
Bare except clauses are a fantastic way to find your HTTP requests
eating your ^C. I replaced all bare excepts with Exception if I could
not find a list of exceptions that could be thrown.
Modulo formatting is py2 (and C printf) style, its arcane and incredibly
hard to read for large formats.
I used keyed .formats where there were more than a few format specifiers
This adds newlines after blocks and in other logical places to assist
with reading the code. Additionally, comments that were too long to
remain inline within a 120 character limit have been moved above the
line they reference.
NB: Due to, I assume, EDDN relay de-duplication of messages, it's been
difficult to 100% test this. No errors thrown, and stock/release EDMC
also doesn't result in a new message arriving at my EDDN consumer.