gavo.stc.utypeast module¶
Parse utype sets into ASTs.
The rough plan is to build an ElementTree from a sequence of utype/value pairs (as returned by utypegen.getUtypes). This ElementTree can then be used to build an AST using stcxast. The ElementTree contains common.ColRefs and thus cannot be serialized to an XML string.
Most of the magic happens in utypeParseToTree, where the utypes are dissected; it is important that the utypes sequence passed to this is sorted such that utypes for things below an STC-X node are actually immediately below the utype pair for their parent.
- gavo.stc.utypeast.morphUtypes(morphers, utypeSeq)[source]¶
returns a morphed sequence of utype/value pairs.
morphers is a dictionary of utypes to handling generators. Each of those most take a utype and a value and generate utype/value pairs.
This is used here to fix the abominations where system elements become values in utype representation.
- gavo.stc.utypeast.parseFromUtypes(utypeSeq)[source]¶
returns an STC AST for a sequence of utype-value pairs.
- gavo.stc.utypeast.utypePairsToTree(utypes, nameQualifier=<function STCElement>)[source]¶
returns an ElementTree from a sequence of (utype, value) pairs.
nameQualifier(str) -> anything is a function producing element names.
The utypes are processed as they come in. In practice this means you should sort them (or similar).
The utype can be none, meaning “Use last node”.