gavo.stc.stcxgen module

Converting ASTs to/from STC-X.

The basic idea for conversion to STC-X is that for every ASTNode in dm, there is a serialize_<classname> function returning some xmlstan. In general they should handle the case when their argument is None and return None in that case.

Traversal is done manually (i.e., by each serialize_X method) rather than globally since the children in the AST may not have the right order to keep XSD happy, and also since ASTs are actually a bit more complicated than trees (e.g., coordinate frames usually have multiple parents).

class gavo.stc.stcxgen.Context(rootNode)[source]

Bases: object

is a generation context.

It is used to pass around genration-related information. Right now, that’s primarily the root node.

getPosForInterval(node)[source]
gavo.stc.stcxgen.addId(node)[source]

adds a synthetic id attribute to node unless it’s already there.

gavo.stc.stcxgen.astToStan(rootNode, stcRoot)[source]

returns STC stan for the AST rootNode wrapped in the stcRoot element.

The first coordinate system defined in the AST is always used for the embedded coordinates and areas.

gavo.stc.stcxgen.getSTCXProfile(rootNode)[source]
gavo.stc.stcxgen.isoformatOrNull(val)[source]
gavo.stc.stcxgen.makeAreas(rootNode, context)[source]

serializes the areas contained in rootNode.

This requires all kinds of insane special handling.

gavo.stc.stcxgen.nodeToStan(astNode)[source]

returns xmlstan for an AST node.

gavo.stc.stcxgen.serialize_AllSky(node, context)[source]
gavo.stc.stcxgen.serialize_Box(node, context)[source]
gavo.stc.stcxgen.serialize_Circle(node, context)[source]
gavo.stc.stcxgen.serialize_Convex(node, context)[source]
gavo.stc.stcxgen.serialize_CoordSys(node, context)[source]
gavo.stc.stcxgen.serialize_Difference(node, context)[source]
gavo.stc.stcxgen.serialize_Ellipse(node, context)[source]
gavo.stc.stcxgen.serialize_Intersection(node, context)
gavo.stc.stcxgen.serialize_MultiCompound(node, context)[source]
gavo.stc.stcxgen.serialize_Not(node, context)[source]
gavo.stc.stcxgen.serialize_Polygon(node, context)[source]
gavo.stc.stcxgen.serialize_RedshiftCoo(node, context)
gavo.stc.stcxgen.serialize_RedshiftFrame(node, context)[source]
gavo.stc.stcxgen.serialize_RedshiftInterval(node, context)
gavo.stc.stcxgen.serialize_RefPos(node, context)[source]
gavo.stc.stcxgen.serialize_SpaceCoo(node, context)
gavo.stc.stcxgen.serialize_SpaceFrame(node, context)[source]
gavo.stc.stcxgen.serialize_SpaceInterval(node, context)
gavo.stc.stcxgen.serialize_SpectralCoo(node, context)
gavo.stc.stcxgen.serialize_SpectralFrame(node, context)[source]
gavo.stc.stcxgen.serialize_SpectralInterval(node, context)
gavo.stc.stcxgen.serialize_TimeCoo(node, context)
gavo.stc.stcxgen.serialize_TimeFrame(node, context)[source]
gavo.stc.stcxgen.serialize_TimeInterval(node, context)
gavo.stc.stcxgen.serialize_Union(node, context)
gavo.stc.stcxgen.serialize_VelocityCoo(node, context)
gavo.stc.stcxgen.serialize_VelocityInterval(node, context)
gavo.stc.stcxgen.strOrNull(val)[source]