mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-19 10:27:38 +03:00
companion: Make raw_data.__str__() a little less verbose
NB: We can't use a generator here to make a python object of the data, to then use json.dumps() on because the raw_data is a *string* (decoded from what we received from the CAPI service), and thus it will get encoded as such, i.e. "raw_data": "{\"id\":322... when we want: "raw_data": {"id":322... We do not want to json.loads() that string only to then json.dumps() it because the whole point is that this is the **raw** data to help diagnose any issues with the CAPI service/data. Such a conversion and back could either throw an exception we don't want here (because we want the raw data) or possibly distort things from what was actually received.
This commit is contained in:
parent
bf33f88260
commit
af50a9f59d
@ -158,9 +158,9 @@ class CAPIDataRaw:
|
||||
def __str__(self):
|
||||
"""Return a more readable string form of the data."""
|
||||
capi_data_str = '{'
|
||||
for e in self.raw_data.keys():
|
||||
capi_data_str += f'"{e}":\n{{\n\t"query_time": "{self.raw_data[e].query_time}",\n\t' \
|
||||
f'"raw_data": {self.raw_data[e].raw_data}\n}},\n\n'
|
||||
for k, v in self.raw_data.items():
|
||||
capi_data_str += f'"{k}":\n{{\n\t"query_time": "{v.query_time}",\n\t' \
|
||||
f'"raw_data": {v.raw_data}\n}},\n\n'
|
||||
|
||||
capi_data_str = capi_data_str.removesuffix(',\n\n')
|
||||
capi_data_str += '\n\n}'
|
||||
|
Loading…
x
Reference in New Issue
Block a user