flowserv.util.files module
Helper methods for the reproducible open benchmark platform. Provides methods to (i) read and write files in JSON and YAML format, (ii) create directories, (iii) validate dictionaries, and (iv) to create of unique identifiers.
- flowserv.util.files.cleardir(directory: str)
Remove all files in the given directory.
- Parameters
directory (string) – Path to directory that is being created.
- flowserv.util.files.dirname(key: str) str
Get the parent directory for a given file identifier.
- Parameters
key (str) – Relative file path expression.
- Return type
str
- flowserv.util.files.filepath(key: str, sep: Optional[str] = '/') str
Convert a given file path to a local path.
Replaces the default path separator ‘/’ with the OS-specific separator if it is different from the default one.
- Parameters
key (str) – Relative file path expression.
sep (string, default=OS file path separator) – OS-specific file path separator.
- Return type
str
- flowserv.util.files.join(*args) str
Concatenate a list of values using the key path separator ‘/’.
- Parameters
args (list) – List of argument values.
- Return type
str
- flowserv.util.files.read_buffer(filename: str) IO
Read content from specified file into a BytesIO buffer.
- Parameters
filename (string) – Path tpo file on disk.
- Return type
io.BytesIO
- flowserv.util.files.read_object(filename: str, format: Optional[str] = None) Dict
Load a Json object from a file. The file may either be in Yaml or in Json format.
- Parameters
filename (string or io.BytesIO) – Path to file on disk
format (string, optional) – Optional file format identifier. The default is YAML.
- Return type
dict
- Raises
ValueError –
- flowserv.util.files.write_object(filename: str, obj: Union[Dict, List], format: Optional[str] = None)
Write given dictionary to file as Json object.
- Parameters
filename (string) – Path to output file
obj (dict) – Output object
- Raises
ValueError –