1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-22 20:00:29 +03:00

loadout.py: Collapse the construction of output filename

All the intermediate variables were more a "work in progress" thing.

Tested as still working.
This commit is contained in:
Athanasius 2022-12-05 10:55:53 +00:00
parent e4055530b4
commit c61f235734
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -49,19 +49,11 @@ def export(data: companion.CAPIData, requested_filename: Optional[str] = None) -
query_time = config.get_int('querytime', default=int(time.time()))
# Write
#
# When this is refactored into multi-line CHECK IT WORKS, avoiding the
# brainfart we had with dangling commas in commodity.py:export() !!!
#
output_path = pathlib.Path(config.get_str('outdir'))
output_filename = pathlib.Path(
ship + '.' + time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime(query_time)) + '.txt'
)
# Can't re-use `filename`, different type
file_name = output_path / output_filename
#
# When this is refactored into multi-line CHECK IT WORKS, avoiding the
# brainfart we had with dangling commas in commodity.py:export() !!!
#
with open(file_name, 'wt') as h:
with open(
pathlib.Path(config.get_str('outdir')) / pathlib.Path(
ship + '.' + time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime(query_time)) + '.txt'
),
'wt'
) as h:
h.write(string)