Skip to content
Snippets Groups Projects

DOC: Fix and extend documentation on inheritance

Merged Florian Spreckelsen requested to merge f-doc-inheritance into dev
All threads resolved!
Files
10
@@ -431,14 +431,39 @@ class Entity(object):
+3
def add_parent(self, parent=None, **kwargs): # @ReservedAssignment
"""Add a parent to this entity.
The first parameter is meant to identify the parent entity. So the method expects an instance of
Entity, an integer or a string here. Even though, by means of the **kwargs parameter you may pass
more parameters to this method. Accepted keywords are: id, name, inheritance. Any other keyword is
ignored right now but this may change in the future.
@param parent: An entity, an id or a name.
@param **kwargs: Accepted keywords: id, name, inheritance.
@raise UserWarning: If neither a 'parent' parameter, nor the 'id', nor 'name' parameter is passed to this method.
Parameters
----------
parent : Entity or int or str or None
The parent entity, either specified by the Entity object
itself, or its id or its name. Default is None.
**kwargs : dict, optional
Additional keyword arguments for specifying the parent by
name or id, and for specifying the mode of inheritance.
id : int
Integer id of the parent entity. Ignored if `parent`
is not None.
name : str
Name of the parent entity. Ignored if `parent is not
none`.
inheritance : str
One of ``obligatory``, ``recommended``, ``suggested``, or ``fix``. Specifies the
minimum importance which parent properties need to have to be inherited by this
entity. If no `inheritance` is given, no properties will be inherited by the child.
This parameter is case-insensitive.
Note that the behaviour is currently not yet specified when assigning parents to
Records, it only works for inheritance of RecordTypes (and Properties).
For more information, it is recommended to look into the
:ref:`data insertion tutorial<tutorial-inheritance-properties>`.
Raises
------
UserWarning
If neither a `parent` parameter, nor the `id`, nor `name`
parameter is passed to this method.
"""
name = (kwargs['name'] if 'name' in kwargs else None)
pid = (kwargs['id'] if 'id' in kwargs else None)
@@ -1435,6 +1460,23 @@ class Property(Entity):
property=property, value=value, **copy_kwargs)
def add_parent(self, parent=None, **kwargs):
"""Add a parent Entity to this Property.
Parameters
----------
parent : Entity or int or str or None, optional
The parent entity
**kwargs : dict, optional
Additional keyword arguments specifying the parent Entity
by id or name, and specifying the inheritance level. See
:py:meth:`Entity.add_parent` for more information. Note
that by default, `inheritance` is set to ``fix``.
See Also
--------
Entity.add_parent
"""
copy_kwargs = kwargs.copy()
if 'inheritance' not in copy_kwargs:
@@ -1513,6 +1555,24 @@ class RecordType(Entity):
**copy_kwargs)
def add_parent(self, parent=None, **kwargs):
"""Add a parent to this RecordType
Parameters
----------
parent : Entity or int or str or None, optional
The parent entity, either specified by the Entity object
itself, or its id or its name. Default is None.
**kwargs : dict, optional
Additional keyword arguments specifying the parent Entity by id or
name, and specifying the inheritance level. See
:py:meth:`Entity.add_parent` for more information. Note
that by default, `inheritance` is set to ``obligatory``.
See Also
--------
Entity.add_parent
"""
copy_kwargs = kwargs.copy()
if 'inheritance' not in copy_kwargs:
Loading