exarl.candlelib.file_utils

Module Contents

Functions

urlretrieve(url, filename, reporthook=None, data=None)

get_file(fname, origin, untar=False, md5_hash=None, cache_subdir='common', datadir=None)

Downloads a file from a URL if it not already in the cache.

validate_file(fpath, md5_hash)

Validates a file against a MD5 hash

exarl.candlelib.file_utils.urlretrieve(url, filename, reporthook=None, data=None)
exarl.candlelib.file_utils.get_file(fname, origin, untar=False, md5_hash=None, cache_subdir='common', datadir=None)

Downloads a file from a URL if it not already in the cache. Passing the MD5 hash will verify the file after download as well as if it is already present in the cache.

Parameters
  • fname (string) – name of the file

  • origin (string) – original URL of the file

  • untar (boolean) – whether the file should be decompressed

  • md5_hash (string) – MD5 hash of the file for verification

  • cache_subdir (string) – directory being used as the cache

  • datadir (string) – if set, datadir becomes its setting (which could be e.g. an absolute path) and cache_subdir no longer matters

Returns

Path to the downloaded file

exarl.candlelib.file_utils.validate_file(fpath, md5_hash)

Validates a file against a MD5 hash

Parameters
  • fpath (string) – path to the file being validated

  • md5_hash (string) – the MD5 hash being validated against

Returns

boolean – Whether the file is valid