Skip to content

Commit

Permalink
feat: 'prices' option in spansh and eddblink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eyeonus committed Apr 24, 2024
1 parent 3e8a5bb commit 2e1fe85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tradedangerous/plugins/eddblink_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 0 additions & 7 deletions tradedangerous/plugins/spansh_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ 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):
super().__init__(*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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 2e1fe85

Please sign in to comment.