eggshell.utils

Utitility functions.

Module Contents

eggshell.utils.paths[source]
eggshell.utils.LOGGER[source]
eggshell.utils.archive(resources, format='tar', dir_output=None, mode=None)[source]

Compresses a list of files into an archive.

Parameters:
  • resources – list of files to be stored in archive
  • format – archive format. Options: tar (default), zip
  • dir_output – path to output folder (default: tempory folder)
  • mode

    for format=’tar’: ‘w’ or ‘w:’ open for writing without compression ‘w:gz’ open for writing with gzip compression ‘w:bz2’ open for writing with bzip2 compression ‘w|’ open an uncompressed stream for writing ‘w|gz’ open a gzip compressed stream for writing ‘w|bz2’ open a bzip2 compressed stream for writing

    for foramt=’zip’: read “r”, write “w” or append “a”

Return str:

archive path/filname.ext

eggshell.utils.download_file(url, out=None, verify=False)[source]
eggshell.utils.local_path(url)[source]
eggshell.utils.download(url, cache=False)[source]

Downloads URL using the Python requests module to the current directory.

Parameters:
  • cache – if True then files will be downloaded to a cache directory.
  • url – url adress of the target file location
Return str:

filename

eggshell.utils.extract_archive(resources, dir_output=None)[source]

extracts archives (tar/zip)

Parameters:
  • resources – list of archive files (if netCDF files are in list, they are passed and returnd as well in the return).
  • dir_output – define a directory to store the results (default: tempory folder).
Return list:

[list of extracted files]

eggshell.utils.rename_complexinputs(complexinputs)[source]

TODO: this method is just a dirty workaround to rename input files according to the url name.

eggshell.utils.address_append(address)[source]

Formats a URL/URI to be more easily read with libraries such as “rasterstats”

Parameters:address – URL/URI to a potential zip or tar file
Returns:URL/URI prefixed for archive type