app.model.lib.util#
Functions#
|
|
|
Check if the given string value represents a finite float. |
|
Trim the whitespace from all the lines in the given string. |
|
Create a zip file from the given CSV files (as bytes) |
|
Group the items in the collection by their |
|
Separates words in camelCased strings with spaces |
|
Downloads the data from the given URL into the target filename |
|
Extracts the given gzip file. |
|
Extracts individual files from a tar file into the given `target_dir`. |
|
Reads the contents of a file, if it exists, and interpret them as a |
|
|
|
|
Module Contents#
- app.model.lib.util.is_non_negative_float(string: str, *, isnan_check: bool)[source]#
Check if the given string value represents a finite float.
This is used for validating data coming from Excel spreadsheets. It’s a bit hacky, there might be cleaner approaches.
- app.model.lib.util.trim_lines(string: str)[source]#
Trim the whitespace from all the lines in the given string.
- app.model.lib.util.createzip(csv_data: list[tuple[str, bytes]]) io.BytesIO[source]#
Create a zip file from the given CSV files (as bytes)
- app.model.lib.util.group_by_unique_name(collection: Iterable) dict[source]#
Group the items in the collection by their
name.Raises an error if there is more than one element with the same name.
- app.model.lib.util.humanize_camelcased_string(string: str)[source]#
Separates words in camelCased strings with spaces
- app.model.lib.util.download_file(url: str, filename: str)[source]#
Downloads the data from the given URL into the target filename
- app.model.lib.util.gunzip(path: pathlib.Path, extracted_path: pathlib.Path | None = None)[source]#
Extracts the given gzip file.
If no output path is given, removes the
.gzsuffix and uses that as the output path.
- app.model.lib.util.untar(path: pathlib.Path, target_dir: pathlib.Path, file_list: list[str])[source]#
Extracts individual files from a tar file into the given `target_dir`.
File paths inside the tar file are listed in `file_list`.