Debian Codegraph @

gavo/stc/utypegen.py

raw symbols SCIP
1 """
2 Generating a utype/value sequence for ASTs.
3
4 Yet another insane serialization for an insane data model. Sigh.
5
6 The way we come up with the STC utypes here is described in an IVOA note.
7
8 Since the utypes are basically xpaths into STC-X, there is not terribly
9 much we need to do here. However, due to STC-X being a nightmare,
10 certain rules need to be formulated what utypes to generate.
11
12 Here, we use UtypeMakers for this. There's a default UtypeMaker
13 that implements the basic algorithm of the STC note (in iterUtypes,
14 a method that yields all utype/value pairs for an STC-X node, which
15 is a stanxml Element).
16
17 To customize what is being generated, define _gener_<child name>
18 methods, where <child name> is a key within the dictionaries
19 returned by stanxml.Element's getChildDict method.
20
21 To make the definition of the _gener_ methods easier, there's
22 the handles decorator that you can pass a list of such child names.
23 """
24
25 #c Copyright 2008-2025, the GAVO project <[email protected]>
26 #c
27 #c This program is free software, covered by the GNU GPL. See the
28 #c COPYING file in the source distribution.
29
30
31 from gavoscip-python python gavodachs 2.13 gavo/__init__: import utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:
32 from gavo.stcscip-python python gavodachs 2.13 `gavo.stc`/__init__: import commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:
33 from gavo.stcscip-python python gavodachs 2.13 `gavo.stc`/__init__: import stcxgenscip-python python gavodachs 2.13 `gavo.stc.stcxgen`/__init__:
34 from gavo.stc.stcxscip-python python gavodachs 2.13 `gavo.stc.stcx`/__init__: import STCscip-python python gavodachs 2.13 `gavo.stc.stcx`/STC#
35
36
37 #################### utype maker definition
38
39 def handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(seqscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(seq)):
40 """is a decorator for UtypeMaker methods.
41
42 It adds a "handles" attribute as evaluated by AutoUtypeMaker.
43 """
44 def decoscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().deco().(methscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().deco().(meth)):
45 methscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().deco().(meth).handles = seqscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(seq)
46 return methscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().deco().(meth)
47 return decoscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().deco().
48
49
50 class UtypeMaker_tscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#(typescip-python python python-stdlib 3.11 builtins/type#):
51 """A metaclass to facilite easy definition of UtypeMakers.
52
53 This metaclass primarily operates on the handles hints left by the
54 decorator.
55 """
56 def __init__scip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(clsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(cls), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(name), basesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(bases), dictscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(dict)):
57 typescip-python python python-stdlib 3.11 builtins/type#.__init__scip-python python python-stdlib 3.11 builtins/type#__init__().(clsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(cls), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(name), basesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(bases), dictscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(dict))
58 clsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(cls)._createHandlesMethodsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(listscip-python python python-stdlib 3.11 builtins/list#(dictscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#__init__().(dict).values()))
59
60 def _createHandlesMethodsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(clsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(cls), itemsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(items)):
61 for item in itemsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(items):
62 for name in getattrscip-python python python-stdlib 3.11 builtins/getattr().(item, "handles", ()):
63 setattr(clsscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#_createHandlesMethods().(cls), "_gener_"+name, item)
64
65
66 class UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#(objectscip-python python python-stdlib 3.11 builtins/object#, metaclass=UtypeMaker_tscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker_t#):
67 """An object encapsulating information on how to turn a stanxml
68 node into a sequence of utype/value pairs.
69
70 This is an "universal" base, serving as a simple default.
71 Any class handling specific node types must fill out at least
72 the rootType attribute, giving the utype at which this UtypeMaker
73 should kick in.
74
75 By default, utype/value pairs are only returned for nonempty
76 element content. To change this, define _gener_<name>(node,
77 prefix) -> iterator methods.
78
79 The actual pairs are retrieved by calling iterUtypes(node,
80 parentPrefix).
81 """
82
83 # attributes that don't get serialized to utypes per spec
84 bannedAttributesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#bannedAttributes. = setscip-python python python-stdlib 3.11 builtins/set#("id frame_id coord_system_id unit"
85 " pos_angle_unit pos_unit spectral_unit time_unit"
86 " vel_time_unit gen_unit xsi:type ucd xmlns:stc xmlns xmlns:xsi"
87 " xsi:schemaLocation".splitscip-python python python-stdlib 3.11 builtins/str#split().())
88
89 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#rootType. = None
90
91 def _generPlainscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(prefix)):
92 childType = utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(prefix), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(name))
93 maker = _getUtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_getUtypeMaker.(childType)
94 for item in childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(child):
95 for pair in maker.iterUtypes(item, childType):
96 yield pair
97
98 def _gener__colRefscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(prefix)):
99 yield prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(prefix), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_gener__colRef().(child)[0]
100
101 def iterUtypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(self), nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(prefix)):
102 children = nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node).getChildDict()
103 if nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node).text_:
104 yield prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(prefix), nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node).text_
105 for attName, name in nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node).iterAttNames():
106 if name not in selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(self).bannedAttributesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#bannedAttributes.:
107 val = getattrscip-python python python-stdlib 3.11 builtins/getattr().(nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(node), attName)
108 if val is not None:
109 yield "%s.%s"%(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(prefix), name.split(":")[-1]), val
110 for name, child in children.items():
111 handler = getattrscip-python python python-stdlib 3.11 builtins/getattr().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(self), "_gener_"+name, selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(self)._generPlainscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().)
112 for pair in handler(name, child, prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(prefix)):
113 yield pair
114
115
116 class _NotImplementedUtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#(UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#):
117 def _generPlainscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(prefix)):
118 raise commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.STCNotImplementedErrorscip-python python gavodachs 2.13 `gavo.stc.common`/STCNotImplementedError#("Cannot create utypes for %s yet."%
119 selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_NotImplementedUtypeMaker#_generPlain().(self).utypeFrag)
120
121
122 #################### utype specific makers
123
124
125 class _CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#(UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#):
126 @handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.stcRefPositionsscip-python python gavodachs 2.13 `gavo.stc.common`/stcRefPositions.)
127 def _refPosscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(prefix)):
128 if namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(name)!='UNKNOWNRefPos':
129 yield utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(prefix), "ReferencePosition"), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(name)
130 for pair in selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(self)._generPlainscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().("ReferencePosition", childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#_refPos().(prefix)):
131 yield pair
132
133
134 class TimeFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#(_CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#):
135 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#rootType. = "AstroCoordSystem.TimeFrame"
136 @handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.stcTimeScalesscip-python python gavodachs 2.13 `gavo.stc.common`/stcTimeScales.)
137 def _timeScalescip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(prefix)):
138 yield utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(prefix), "TimeScale"), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeFrameMaker#_timeScale().(name)
139
140
141 class SpaceFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#(_CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#):
142 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#rootType. = "AstroCoordSystem.SpaceFrame"
143
144 @handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.stcSpaceRefFramesscip-python python gavodachs 2.13 `gavo.stc.common`/stcSpaceRefFrames.)
145 def _coordFramescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(prefix)):
146 myPrefix = utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(prefix), "CoordRefFrame")
147 yield myPrefix, namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(name)
148 for pair in selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(self)._generPlainscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#_generPlain().(None, childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFrame().(child), myPrefix):
149 yield pair
150
151 @handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.stcCoordFlavorsscip-python python gavodachs 2.13 `gavo.stc.common`/stcCoordFlavors.)
152 def _coordFlavorscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix)):
153 prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix) = utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix), "CoordFlavor")
154 yield prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(name)
155 if childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(child):
156 if childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(child)[0].coord_naxes!="2":
157 yield utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix), "coord_naxes"), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(child)[0].coord_naxes
158 yield utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(prefix), "handedness"), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpaceFrameMaker#_coordFlavor().(child)[0].handedness
159
160
161 class RedshiftFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#(_CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#):
162 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#rootType. = "AstroCoordSystem.RedshiftFrame"
163
164 def iterUtypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(self), nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(node), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(prefix)):
165 for pair in _CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#.iterUtypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(self), nodescip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(node), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/RedshiftFrameMaker#iterUtypes().(prefix)):
166 yield pair
167
168
169 class SpectralFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpectralFrameMaker#(_CoordFrameMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_CoordFrameMaker#):
170 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/SpectralFrameMaker#rootType. = "AstroCoordSystem.SpectralFrame"
171
172
173 class _TimeValueMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#(UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#):
174 @handlesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/handles().(["ISOTime", "JDTime", "MJDTime"])
175 def _absoluteTimescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(self), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(name), childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(child), prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(prefix)):
176 yield utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(prefix), "xtype"), namescip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(name)
177 for item in childscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(child):
178 for pair in selfscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(self).iterUtypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#iterUtypes().(item, prefixscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#_absoluteTime().(prefix)):
179 yield pair
180
181
182 class TimeInstantMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeInstantMaker#(_TimeValueMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#):
183 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/TimeInstantMaker#rootType. = "AstroCoords.Time.TimeInstant"
184
185 class StartTimeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/StartTimeMaker#(_TimeValueMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#):
186 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/StartTimeMaker#rootType. = "AstroCoordArea.TimeInterval.StartTime"
187
188 class StopTimeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/StopTimeMaker#(_TimeValueMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_TimeValueMaker#):
189 rootTypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/StopTimeMaker#rootType. = "AstroCoordArea.TimeInterval.StopTime"
190
191
192 #################### toplevel code
193
194 def utypejoinscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(*utypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(utypes)):
195 return ".".joinscip-python python python-stdlib 3.11 builtins/str#join().(u for u in utypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/utypejoin().(utypes) if u)
196
197
198 # A resolver of element names to their handling classes. For most
199 # elements, this is just a plain UtypeMaker.
200 _getUtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_getUtypeMaker. = utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.buildClassResolverscip-python python gavodachs 2.13 `gavo.utils.codetricks`/buildClassResolver().(
201 UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#,
202 listscip-python python python-stdlib 3.11 builtins/list#(globals().valuesscip-python python python-stdlib 3.11 builtins/dict#values().()),
203 defaultscip-python python gavodachs 2.13 `gavo.utils.codetricks`/buildClassResolver().(default)=UtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/UtypeMaker#(),
204 instancesscip-python python gavodachs 2.13 `gavo.utils.codetricks`/buildClassResolver().(instances)=True,
205 keyscip-python python gavodachs 2.13 `gavo.utils.codetricks`/buildClassResolver().(key)=lambda obj:obj.rootType)
206
207
208 def getUtypesscip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(astscip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(ast), includeDMURIscip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(includeDMURI)=False, suppressXtypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(suppressXtype)=True):
209 """returns a lists of utype/value pairs for an STC AST.
210
211 If you pass includeDMURI, a utype/value pair for the data model URI will
212 be generated in addition to what comes in from ast.
213 """
214 cst = stcxgenscip-python python gavodachs 2.13 `gavo.stc.stcxgen`/__init__:.astToStanscip-python python gavodachs 2.13 `gavo.stc.stcxgen`/astToStan().(astscip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(ast), STCscip-python python gavodachs 2.13 `gavo.stc.stcx`/STC#.STCSpecscip-python python gavodachs 2.13 `gavo.stc.stcx`/STC#STCSpec#)
215 utypes = []
216 for utype, val in _getUtypeMakerscip-python python gavodachs 2.13 `gavo.stc.utypegen`/_getUtypeMaker.("").iterUtypes(cst, ""):
217 if val is None or val=='':
218 continue
219 if suppressXtypescip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(suppressXtype):
220 if utype.endswith("xtype"):
221 continue
222 utypes.appendscip-python python python-stdlib 3.11 builtins/list#append().(("stc:"+utype, val))
223 if includeDMURIscip-python python gavodachs 2.13 `gavo.stc.utypegen`/getUtypes().(includeDMURI):
224 utypes.appendscip-python python python-stdlib 3.11 builtins/list#append().(("stc:DataModel.URI", commonscip-python python gavodachs 2.13 `gavo.stc.common`/__init__:.STCNamespacescip-python python gavodachs 2.13 `gavo.stc.common`/STCNamespace.))
225 utypes.sortscip-python python python-stdlib 3.11 builtins/list#sort().()
226 return utypes