Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _load_file(self, file, archive=False, cache_dir=None):
if not cache_dir:
if hasattr(self, "cache_dir"):
cache_dir = self.cache_dir
else:
from tempfile import mkdtemp
cache_dir = mkdtemp()
cached_file = Path(cache_dir) / file
if cached_file.exists():
return cached_file
suffix = self.archive_suffix if archive else ""
file_url = self.base_url + file + suffix
print("downloading", file_url)
return http_get(file_url, cached_file, ignore_tardir=True)