floodlight.io.utils
- floodlight.io.utils.download_from_url(path)[source]
Downloads file from URL.
- Parameters
path (str) – URL path to download data from
- Returns
data
- Return type
AnyStr
- floodlight.io.utils.extract_zip(filepath, target, archive_type='zip')[source]
Extracts the content of an archive to disk.
- Parameters
filepath (str) – Path to file.
target (str) – Target to extract files to.
archive_type (“zip”, optional) – Type of archive, like zip, rar, gzip, etc.
- Return type
None
- floodlight.io.utils.get_and_convert(dic, key, value_type, default=None)[source]
Performs dictionary get and type conversion simultaneously.
- Parameters
dic (dict) – Dictionary to be queried.
key (Any) – Key to be looked up.
value_type (type) – Desired output type the value should be cast into.
default (Any, optional) – Return value if key is not in dic, defaults to None.
- Returns
value – Returns the value for key if key is in dic, else default. Tries type conversion to type(value) = value_type. If type conversion fails, e.g. by trying to force something like float(None) due to a missing dic entry, value is returned in its original data type.
- Return type
value_type