gavo.dm.common module¶
Common code for new-style Data Model support.
In particular, this defines a hierarchy of Annotation objects. The annotation of DaCHS tables is an ObjectAnnotation, the other Annotation classes (conceptually, all are key-value pairs) make up their inner structure.
- class gavo.dm.common.AnnotationBase(name, instance)[source]¶
Bases:
object
A base class for of structs.
Basically, these are pairs of a role name and something else, which depends on the actual subclass (e.g., an atomic value, a reference, a sequence of key-value pairs, a sequence of other objects, …).
They have a method getVOT(ctx, instance) -> xmlstan, which, using a votablewrite.Context ctx, will return mapping-document conformant VOTable xmlstan; instance is the rsc/rscdef structure the annotation is produced for.
Use asSIL() to retrieve a simple string representation.
Compound annotations (sequences, key-value pairs) should use add(thing) to build themselves up.
AnnotationBase is abstract and doesn’t implement some of these methods.
- class gavo.dm.common.AtomicAnnotation(name=None, value=None, unit=None, ucd=None, instance=None)[source]¶
Bases:
AnnotationBase
An annotation of an atomic value, i.e., a key-value pair.
These can take optional metadata.
- class gavo.dm.common.CollectionAnnotation(name, type, instance)[source]¶
Bases:
AnnotationBase
,_WithMapCopyMixin
A collection contains 0..n things of the same type.
- class gavo.dm.common.DatatypeAnnotation(name, type, instance)[source]¶
Bases:
_AttributeGroupAnnotation
An annotation for a datatype.
Datatypes are essentially simple groups of attributes; they are used within objects (e.g., to group photometry points, or positions, or the like.
- class gavo.dm.common.ObjectAnnotation(name, type, instance)[source]¶
Bases:
_AttributeGroupAnnotation
An annotation for an object.
Objects are used for actual DM instances. In particular, every annotation of a DaCHS table is rooted in an object.
- class gavo.dm.common.TableRelativeAnnotation(name, instance)[source]¶
Bases:
AnnotationBase
A base class for annotations that must be adapted or discarded when an annotation is copied.
- gavo.dm.common.completeVODMLId(ctx, roleName)[source]¶
completes roleName to a full (standard) vo-dml id.
This is based on what the containerTypeSet context manager leaves in the VOTable serialisation context ctx.
- gavo.dm.common.containerTypeSet(ctx, typeName)[source]¶
a context manager to control the type currently serialised in a VOTable.
ctx is a VOTable serialisation context (that we liberally hack into).
- gavo.dm.common.parseTypeName(typename)[source]¶
returns modelname, package (None for the empty package), name for a VO-DML type name.
Malformed names raise a ValueError.
>>> parseTypeName("dm:type") ('dm', None, 'type') >>> parseTypeName("dm:pck.type") ('dm', 'pck', 'type') >>> parseTypeName(":malformed.typeid") Traceback (most recent call last): ValueError: ':malformed.typeid' is not a valid VO-DML type name