diff --git a/bindings/python/dlite-entity-python.i b/bindings/python/dlite-entity-python.i index c65c9ede2..6700e1ef4 100644 --- a/bindings/python/dlite-entity-python.i +++ b/bindings/python/dlite-entity-python.i @@ -376,19 +376,38 @@ def get_instance( f'"{self.uri if self.uri else self.meta.uri}"' ) - meta = property(get_meta, doc="Reference to the metadata of this instance.") - dimensions = property( - lambda self: dict((d.name, int(v)) - for d, v in zip(self.meta['dimensions'], - self.get_dimensions())), - doc='Dictionary with dimensions name-value pairs.') - properties = property(lambda self: - {p.name: self[p.name] for p in self.meta['properties']}, - doc='Dictionary with property name-value pairs.') - is_data = property(_is_data, doc='Whether this is a data instance.') - is_meta = property(_is_meta, doc='Whether this is a metadata instance.') - is_metameta = property(_is_metameta, - doc='Whether this is a meta-metadata instance.') + @property + def meta(self): + """Reference to the metadata of this instance.""" + return self.get_meta() + + @property + def dimensions(self): + """Dictionary with dimensions name-value pairs.""" + return dict( + (d.name, int(v)) + for d, v in zip(self.meta['dimensions'], self.get_dimensions()) + ) + + @property + def properties(self): + """Dictionary with property name-value pairs.""" + return {p.name: self[p.name] for p in self.meta['properties']} + + @property + def is_data(self): + """Whether this is a data instance.""" + return self._is_data() + + @property + def is_meta(self): + """Whether this is a metadata instance.""" + return self._is_meta() + + @property + def is_metameta(self): + """Whether this is a meta-metadata instance.""" + return self._is_metameta() @classmethod def from_metaid(cls, metaid, dimensions, id=None): diff --git a/bindings/python/dlite-entity.i b/bindings/python/dlite-entity.i index f1d8e731c..0e5a0efd9 100644 --- a/bindings/python/dlite-entity.i +++ b/bindings/python/dlite-entity.i @@ -244,24 +244,22 @@ struct _Triple { * Instance * -------- */ %feature("docstring", "\ -Returns a new instance. - -Instance(metaid=None, dims=None, id=None, url=None, storage=None, driver=None, - location=None, options=None, dimensions=None, properties=None, - description=None) - - Is called from one of the following class methods defined in dlite.py: - - - from_metaid(cls, metaid, dimensions, id=None) - - from_url(cls, url, metaid=None) - - from_storage(cls, storage, id=None, metaid=None) - - from_location(cls, driver, location, options=None, id=None) - - from_json(cls, jsoninput, id=None, metaid=None) - - from_bson(cls, bsoninput) - - from_dict(cls, d, id=None, single=None, check_storages=True) - - create_metadata(cls, uri, dimensions, properties, description) - - For details, see the documentation for the class methods. +Represents a DLite instance. + +This is the most central class in DLite. It has a complex `__init__()` +method and is intended to be instantiated with one of the following class +methods: + + - from_metaid(cls, metaid, dimensions, id=None) + - from_url(cls, url, metaid=None) + - from_storage(cls, storage, id=None, metaid=None) + - from_location(cls, driver, location, options=None, id=None) + - from_json(cls, jsoninput, id=None, metaid=None) + - from_bson(cls, bsoninput) + - from_dict(cls, d, id=None, single=None, check_storages=True) + - create_metadata(cls, uri, dimensions, properties, description) + +For details, see the documentation of the individual class methods. ") _DLiteInstance; %apply(int *IN_ARRAY1, int DIM1) {(int *dims, int ndims)};