gavo.stc.utypegen module

Generating a utype/value sequence for ASTs.

Yet another insane serialization for an insane data model. Sigh.

The way we come up with the STC utypes here is described in an IVOA note.

Since the utypes are basically xpaths into STC-X, there is not terribly much we need to do here. However, due to STC-X being a nightmare, certain rules need to be formulated what utypes to generate.

Here, we use UtypeMakers for this. There’s a default UtypeMaker that implements the basic algorithm of the STC note (in iterUtypes, a method that yields all utype/value pairs for an STC-X node, which is a stanxml Element).

To customize what is being generated, define _gener_<child name> methods, where <child name> is a key within the dictionaries returned by stanxml.Element’s getChildDict method.

To make the definition of the _gener_ methods easier, there’s the handles decorator that you can pass a list of such child names.

class gavo.stc.utypegen.RedshiftFrameMaker[source]

Bases: _CoordFrameMaker

iterUtypes(node, prefix)[source]
rootType = 'AstroCoordSystem.RedshiftFrame'
class gavo.stc.utypegen.SpaceFrameMaker[source]

Bases: _CoordFrameMaker

rootType = 'AstroCoordSystem.SpaceFrame'
class gavo.stc.utypegen.SpectralFrameMaker[source]

Bases: _CoordFrameMaker

rootType = 'AstroCoordSystem.SpectralFrame'
class gavo.stc.utypegen.StartTimeMaker[source]

Bases: _TimeValueMaker

rootType = 'AstroCoordArea.TimeInterval.StartTime'
class gavo.stc.utypegen.StopTimeMaker[source]

Bases: _TimeValueMaker

rootType = 'AstroCoordArea.TimeInterval.StopTime'
class gavo.stc.utypegen.TimeFrameMaker[source]

Bases: _CoordFrameMaker

rootType = 'AstroCoordSystem.TimeFrame'
class gavo.stc.utypegen.TimeInstantMaker[source]

Bases: _TimeValueMaker

rootType = 'AstroCoords.Time.TimeInstant'
class gavo.stc.utypegen.UtypeMaker[source]

Bases: object

An object encapsulating information on how to turn a stanxml node into a sequence of utype/value pairs.

This is an “universal” base, serving as a simple default. Any class handling specific node types must fill out at least the rootType attribute, giving the utype at which this UtypeMaker should kick in.

By default, utype/value pairs are only returned for nonempty element content. To change this, define _gener_<name>(node, prefix) -> iterator methods.

The actual pairs are retrieved by calling iterUtypes(node, parentPrefix).

bannedAttributes = {'coord_system_id', 'frame_id', 'gen_unit', 'id', 'pos_angle_unit', 'pos_unit', 'spectral_unit', 'time_unit', 'ucd', 'unit', 'vel_time_unit', 'xmlns', 'xmlns:stc', 'xmlns:xsi', 'xsi:schemaLocation', 'xsi:type'}
iterUtypes(node, prefix)[source]
rootType = None
class gavo.stc.utypegen.UtypeMaker_t(name, bases, dict)[source]

Bases: type

A metaclass to facilite easy definition of UtypeMakers.

This metaclass primarily operates on the handles hints left by the decorator.

gavo.stc.utypegen.getUtypes(ast, includeDMURI=False, suppressXtype=True)[source]

returns a lists of utype/value pairs for an STC AST.

If you pass includeDMURI, a utype/value pair for the data model URI will be generated in addition to what comes in from ast.

gavo.stc.utypegen.handles(seq)[source]

is a decorator for UtypeMaker methods.

It adds a “handles” attribute as evaluated by AutoUtypeMaker.

gavo.stc.utypegen.utypejoin(*utypes)[source]