Section API

class odml2.Section(uuid, document, is_link=False)

NOTICE: Section initialization is usually done by the API

keys()

List or generator over all property names (keys)

__delitem__(key)

Remove a property from the section. If the property is a section property the whole subtree of the document is removed.

Parameters:key (str) – The name of the property to remove.
__getitem__(key)

Access the target of certain property.

If the property is a section property with a single section the result is a Section object for other section properties the result is a list of sections.

If the property points to an odml Value the result is the values value.

Parameters:key (str) – The name of the accessed property.
Returns:Depending of the target a single section, a list of sections or the value of the targeted value object.
__iter__()

Iterate over all targets of all properties of the section. Depending on the property the target is either a list of Section objects or a Value.

Returns:A generator over all property targets
__len__()

The number of properties in the section.

Return type:int
__setitem__(key, element)

Set the target for a certain property. The target element can be either a Section, SB, Value or any allowed value type.

If the element is a Section the section is linked to this property if the parent if it already exists in the document. Otherwise the section is copied.

If the element is a SB object an analogous section will be created in the document.

If the element is a Value the value is used as target for the property. In all other cases a Value object will be constructed from the element if this is supported for the elements type.

Parameters:
  • key (str) – The name of the property.
  • element (any) – The target element for the given property.
document

Reference to the document the section belongs to.

Type:Document
get(key, default=None)

Access the target object of a certain property.

If the property is a section property the result is a list of Section objects.

If the property is a value property the result is a single Value.

Parameters:
  • key (str) – The name of the accessed property.
  • default – The default value if the property does not exist.
Returns:

A list of sections or a value

Whether or not the section is a link. Depending on the parent from which the section was accessed the same section can be a link or not a link.

Type:bool
items()

Iterate over all property, property target pairs of the section. Depending on the property the target is either a list of Section objects or a Value.

Returns:A generator over all property, property target pairs
label

The label of the section. The label is an optional, human readable identifier of a section.

Type:str
reference

An URI or path to other data related to this specific section.

Type:str
type

The type of the section. The type names the kind of thing the section represents.

Type:str
uuid

The uuid of the section. This is a read only property.

Type:str
values()

Iterate over all targets of all properties of the section. Depending on the property the target is either a list of Section objects or a Value.

Returns:A generator over all property targets

The section builder SB

class odml2.SB(type, uuid=None, label=None, reference=None, **properties)

A section builder

build(document, parent_uuid=None, parent_prop=None)

Navigation