22 """This module defines YAML I/O for key lsst.daf.base classes."""
30 from .dateTime
import DateTime
31 from .propertyContainer
import PropertyList, getPropertyListState, setPropertyListState, \
32 getPropertySetState, setPropertySetState, PropertySet
37 loaderList = [yaml.Loader, yaml.CLoader]
39 loaderList.append(yaml.FullLoader)
40 except AttributeError:
43 loaderList.append(yaml.UnsafeLoader)
44 except AttributeError:
47 loaderList.append(yaml.SafeLoader)
48 except AttributeError:
56 """Represent an lsst.daf.base.DateTime (as ISO8601-formatted string in TAI)
58 return dumper.represent_scalar(
'lsst.daf.base.DateTime',
59 data.toString(DateTime.TAI))
63 yaml.add_representer(DateTime, dt_representer)
67 """Represent an lsst.daf.base.PropertyList as an ordered sequence of
68 name/type/value/comment lists)"""
71 return dumper.represent_sequence(
'lsst.daf.base.PropertyList', result,
76 yaml.add_representer(PropertyList, pl_representer)
80 """Represent an lsst.daf.base.PropertySet as a mapping from names to
84 return dumper.represent_sequence(
'lsst.daf.base.PropertySet', result,
89 yaml.add_representer(PropertySet, ps_representer)
97 """Construct an lsst.daf.base.DateTime from an ISO8601-formatted string in
99 dt = loader.construct_scalar(node)
100 return DateTime(str(dt), DateTime.TAI)
104 """Construct an lsst.daf.base.PropertyList from a YAML pickle-like
108 state = loader.construct_sequence(node, deep=
True)
113 """Construct an lsst.daf.base.PropertyList from a YAML pickle-like
117 state = loader.construct_sequence(node, deep=
True)
122 for loader
in loaderList:
123 yaml.add_constructor(
'lsst.daf.base.PropertyList', pl_constructor, Loader=loader)
124 yaml.add_constructor(
'lsst.daf.base.PropertySet', ps_constructor, Loader=loader)
125 yaml.add_constructor(
'lsst.daf.base.DateTime', dt_constructor, Loader=loader)