speasy.core.codecs.bundled_codecs.hapi.codec module
- class speasy.core.codecs.bundled_codecs.hapi.codec.HapiBaseCodec(loader, saver)[source]
Bases:
CodecInterface- load_variable(variable, file, cache_remote_files=True, **kwargs)[source]
Load a variable from a file. The file can be a local file, a remote file or a file-like object.
- Parameters:
- variablestr
Variable name to load
- fileBuffer or str or io.IOBase
File to load variable from
- cache_remote_filesbool
Whether to cache remote files
- kwargs
Additional keyword arguments, codec specific arguments
- Returns:
- Optional[SpeasyVariable]
The variable loaded
- Raises:
- NotImplementedError
If the method is not implemented
See also
- load_variables(variables, file, cache_remote_files=True, **kwargs)[source]
Load variables from a file. The file can be a local file, a remote file or a file-like object.
- Parameters:
- variablesList[str]
List of variable names to load
- fileBuffer or str or io.IOBase
File to load variables from
- cache_remote_filesbool
Whether to cache remote files
- kwargs
Additional keyword arguments, codec specific arguments
- Returns:
- Optional[Mapping[str, SpeasyVariable]]
A dictionary with the variables loaded
- Raises:
- NotImplementedError
If the method is not implemented
See also
- save_variables(variables, file=None, **kwargs)[source]
Save variables to a file. The file can be a local file, a remote file or a file-like object.
- Parameters:
- variablesList[SpeasyVariable]
List of variables to save
- filestr or io.IOBase
File to save variables to, if None, return the data as bytes
- kwargs
Additional keyword arguments, codec specific arguments
- Returns:
- Union[bool, Buffer]
True if the variables were saved successfully, the data as buffer compatible object if file is None
- Raises:
- NotImplementedError
If the method is not implemented which is an acceptable behavior for read-only codecs
See also
- property supported_extensions
List of supported file extensions, without the dot. Do return extensions that could be ambiguous with other codecs.
- property supported_mimetypes
List of supported mime types.