From 2e1fe85449144c684810d815f835e73124d8ed77 Mon Sep 17 00:00:00 2001 From: eyeonus Date: Wed, 24 Apr 2024 11:13:51 -0600 Subject: [PATCH] feat: 'prices' option in spansh and eddblink spansh and eddblink plugins no longer regenerate the `TradeDangerous.prices` cache file by default The cache file is used to rebuild the database in the event it is lost, corrupted or otherwise damaged. Users can manually perform a backup by running eddblink with the 'prices' option. If not other options are specified, eddblink will only perform the backup If any other options are specified, eg. `-O listings,prices`, eddblink will perform the backup after the import process has completed. --- tradedangerous/plugins/eddblink_plug.py | 7 ++++--- tradedangerous/plugins/spansh_plug.py | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tradedangerous/plugins/eddblink_plug.py b/tradedangerous/plugins/eddblink_plug.py index 0df89feb..c438ef69 100644 --- a/tradedangerous/plugins/eddblink_plug.py +++ b/tradedangerous/plugins/eddblink_plug.py @@ -89,7 +89,8 @@ class ImportPlugin(plugins.ImportPluginBase): 'force': "Force regeneration of selected items even if source file not updated since previous run. " "(Useful for updating Vendor tables if they were skipped during a '-O clean' run.)", 'purge': "Remove any empty systems that previously had fleet carriers.", - 'solo': "Don't download crowd-sourced market data. (Implies '-O skipvend', supercedes '-O all', '-O clean', '-O listings'.)" + 'solo': "Don't download crowd-sourced market data. (Implies '-O skipvend', supercedes '-O all', '-O clean', '-O listings'.)", + "prices": "Backup listings to the TradeDangerous.prices cache file", } def __init__(self, tdb, tdenv): @@ -351,7 +352,7 @@ def run(self): default = True for option in self.options: # if not option in ('force', 'fallback', 'skipvend', 'progbar'): - if not option in ('force', 'skipvend'): + if not option in ('force', 'skipvend', 'prices'): default = False if default: self.options["listings"] = True @@ -508,7 +509,7 @@ def run(self): if self.downloadFile(self.liveListingsPath) or self.getOption("force"): self.importListings(self.liveListingsPath) - if self.getOption("listings"): + if self.getOption("prices"): self.tdenv.NOTE("Regenerating .prices file.") cache.regeneratePricesFile(self.tdb, self.tdenv) diff --git a/tradedangerous/plugins/spansh_plug.py b/tradedangerous/plugins/spansh_plug.py index 0e5f89b9..48cfc329 100644 --- a/tradedangerous/plugins/spansh_plug.py +++ b/tradedangerous/plugins/spansh_plug.py @@ -65,7 +65,6 @@ class ImportPlugin(plugins.ImportPluginBase): 'url': f'URL to download galaxy data from (defaults to {SOURCE_URL})', 'file': 'Local filename to import galaxy data from; use "-" to load from stdin', 'maxage': 'Skip all entries older than specified age in days, ex.: maxage=1.5', - 'listener': 'For use by TD-listener, prevents updating cache from generated prices file', } def __init__(self, *args, **kwargs): @@ -73,7 +72,6 @@ def __init__(self, *args, **kwargs): self.url = self.getOption('url') self.file = self.getOption('file') self.maxage = float(self.getOption('maxage')) if self.getOption('maxage') else None - self.listener = self.getOption('listener') assert not (self.url and self.file), 'Provide either url or file, not both' if self.file and (self.file != '-'): self.file = (Path(self.tdenv.cwDir) / self.file).resolve() @@ -170,11 +168,6 @@ def run(self): f'{total_station_count} st {total_commodity_count} co' ) - with Timing() as timing: - self.print('Exporting to cache...') - cache.regeneratePricesFile(self.tdb, self.tdenv) - self.print(f'Cache export completed in {timedelta(seconds=int(timing.elapsed))!s}') - return False def data_stream(self):