def test_multiple_domains_same_file(): filename_google = build_local_filename( download_url="http://www.google.com/index.html") filename_yahoo = build_local_filename( download_url="http://www.yahoo.com/index.html") assert "index" in filename_google assert "index" in filename_yahoo assert filename_yahoo != filename_google
def cached_path(self, path_or_url): """ When downloading remote files, the default behavior is to name local files the same as their remote counterparts. """ assert path_or_url, "Expected non-empty string for path_or_url" remote_filename = split(path_or_url)[1] if self.is_url_format(path_or_url): # passing `decompress=False` since there is logic below # for stripping decompression extensions for both local # and remote files local_filename = datacache.build_local_filename( download_url=path_or_url, filename=remote_filename, decompress=False) else: local_filename = remote_filename # if we expect the download function to decompress this file then # we should use its name without the compression extension if self.decompress_on_download: local_filename = self._remove_compression_suffix_if_present( local_filename) if len(local_filename) == 0: raise ValueError("Can't determine local filename for %s" % ( path_or_url,)) return join(self.cache_directory_path, local_filename)
def cached_path(self, path_or_url): """ When downloading remote files, the default behavior is to name local files the same as their remote counterparts. """ assert path_or_url, "Expected non-empty string for path_or_url" remote_filename = split(path_or_url)[1] if self.is_url_format(path_or_url): # passing `decompress=False` since there is logic below # for stripping decompression extensions for both local # and remote files local_filename = datacache.build_local_filename( download_url=path_or_url, filename=remote_filename, decompress=False) else: local_filename = remote_filename # if we expect the download function to decompress this file then # we should use its name without the compression extension if self.decompress_on_download: local_filename = self._remove_compression_suffix_if_present( local_filename) if len(local_filename) == 0: raise ValueError("Can't determine local filename for %s" % (path_or_url, )) return join(self.cache_directory_path, local_filename)
def test_url_without_filename(): filename = build_local_filename(download_url="http://www.google.com/") assert filename assert "google" in filename