solidipes.loaders.data_container module

class solidipes.loaders.data_container.DataContainer(initial_data={}, name=None, unique_identifier=None, **kwargs)[source]

Bases: ROCrateMetadata

Container class for other structured data containers.

_data_collection

Dictionary of other DataContainer or arbitrary objects. Set entry to “None” to mark as loadable.

_get_class_validators() list[Validator][source]

Fill the list of validators for this class.

_has_native_attr(key) bool | None[source]

Check if attribute is present, outside of _data_collection, without using __getattr__.

add(key, data=None) None[source]

Add an arbitrary object to the data collection.

class_path = 'solidipes.loaders.data_container.DataContainer'
compatible_viewers: list[Type[Viewer]]

List of compatible Viewer classes. Optionally override this in subclasses. Ideally, update it with self.compatible_viewers[:0] = [new_viewer_class, …]

copy()[source]

Returns a shallow copy without the need to read from disk again.

property data

Load all data if necessary and return it.

Accessing this property for the first time will load the data. If self.__loaded_data has only one entry, returns it directly.

Override the _load_data method in subclasses to define how data is loaded or built using other data containers.

property data_info

Returns a multi-line string with information about data keys.

disable_validator(name: str) None[source]

Disable a specific validator.

enable_validator(name: str) None[source]

Enable a specific validator.

property errors: list[str]

List of validation errors.

get(key)[source]

Get a data object by key, loading it if necessary.

has(key)[source]

Check if data is available in this container.

property is_valid: bool

Evaluate if all validators are passing.

load_all

Load all data.

class loadable(func)

Bases: property

foo(obj, *args, **kwargs)
foo_setter(obj, value, *args, **kwargs) None
property preferred_viewer: Type[Viewer] | None

Returns the default viewer for this data container.

property preferred_viewer_name: str | None

Returns the default viewer name for this data container.

remove(key) None[source]

Remove a data object from the data collection.

property validation_results: list[ValidationResult]

Dictionary of validation results.

property validator_enabled: dict[str, bool]

Dictionary of validator names and enabled status.

view(**kwargs)[source]

View the file using the preferred viewer.

class solidipes.loaders.data_container.TemporaryFile(delete=False, init=True)[source]

Bases: object

add_extensions(extensions) None[source]
fname(ext=None)[source]
getstate()[source]
open(ext=None, options='r')[source]
setstate(state) None[source]
solidipes.loaders.data_container._validators: dict[str, list[Validator]] = {}

Lists of validators for each DataContainer class

class solidipes.loaders.data_container.loadable(func)[source]

Bases: property

foo(obj, *args, **kwargs)[source]
foo_setter(obj, value, *args, **kwargs) None[source]