def _resolve_pairs_list(self, config: Dict[str, Any]) -> None: """ Helper for download script. Takes first found: * -p (pairs argument) * --pairs-file * whitelist from config """ if "pairs" in config: config['exchange']['pair_whitelist'] = config['pairs'] return if "pairs_file" in self.args and self.args["pairs_file"]: pairs_file = Path(self.args["pairs_file"]) logger.info(f'Reading pairs file "{pairs_file}".') # Download pairs from the pairs file if no config is specified # or if pairs file is specified explicitly if not pairs_file.exists(): raise OperationalException( f'No pairs file found with path "{pairs_file}".') config['pairs'] = load_file(pairs_file) config['pairs'].sort() return if 'config' in self.args and self.args['config']: logger.info("Using pairlist from configuration.") config['pairs'] = config.get('exchange', {}).get('pair_whitelist') else: # Fall back to /dl_path/pairs.json pairs_file = config['datadir'] / 'pairs.json' if pairs_file.exists(): config['pairs'] = load_file(pairs_file) if 'pairs' in config: config['pairs'].sort()
def test_load_file_error(tmpdir): testpath = Path(tmpdir) / 'config.json' with pytest.raises(OperationalException, match=r"File .* not found!"): load_file(testpath)