3 gY%@sddlTddlTddlTddlTddlTddlTdZyddlTdZWne k r\dZYnXddl Z e fddZ e fd d Z e fd d Ze fd dZe fddZe fddZddZddZdedddddfddZdeddddddddddf ddZdefddZdeddddddddddddfddZdefdd Zd6d!d"Zd7d#d$Zde efd%d&Zde efd'd(Ze fd)d*Ze fd+d,Zefd-d.Z efd/d0Z!Gd1d2d2e"Z#Gd3d4d4e#d5Z$dS)8)*z3.12TFNc cs4||}zx|jr |jVq WWd|jXdS)z9 Scan a YAML stream and produce scanning tokens. N)Z check_tokenZ get_tokendispose)streamLoaderloaderr>/Users/olari/OneDrive/sandbox/awsBlog2/lambda/yaml/__init__.pyscans  r c cs4||}zx|jr |jVq WWd|jXdS)z9 Parse a YAML stream and produce parsing events. N)Z check_eventZ get_eventr)rrrrrr parses  r c Cs ||}z|jS|jXdS)zj Parse the first YAML document in a stream and produce the corresponding representation tree. N)Zget_single_noder)rrrrrr compose*sr c cs4||}zx|jr |jVq WWd|jXdS)zb Parse all YAML documents in a stream and produce corresponding representation trees. N)Z check_nodeZget_noder)rrrrrr compose_all5s  r c Cs ||}z|jS|jXdS)zd Parse the first YAML document in a stream and produce the corresponding Python object. N)Zget_single_datar)rrrrrr loadAsrc cs4||}zx|jr |jVq WWd|jXdS)z\ Parse all YAML documents in a stream and produce corresponding Python objects. N)Z check_dataget_datar)rrrrrr load_allLs  rcCs t|tS)z Parse the first YAML document in a stream and produce the corresponding Python object. Resolve only basic YAML tags. )r SafeLoader)rrrr safe_loadXsrcCs t|tS)z~ Parse all YAML documents in a stream and produce corresponding Python objects. Resolve only basic YAML tags. )rr)rrrr safe_load_all`src Csdd}|dkrtj}|j}|||||||d} zx|D]} | j| q6WWd| jX|r`|SdS)zl Emit YAML parsing events into a stream. If stream is None, return the produced string instead. N) canonicalindentwidth allow_unicode line_break)ioStringIOgetvalueemitr) eventsrDumperrrrrrrdumpereventrrr rhs    rc  Csd} |dkr,|dkrtj}ntj}|j} ||||||||| | | | d }z,|jx|D]}|j|qZW|jWd|jX| r| SdS)z Serialize a sequence of representation trees into a YAML stream. If stream is None, return the produced string instead. N) rrrrrencodingversiontagsexplicit_start explicit_end)rrBytesIOropen serializecloser)nodesrrrrrrrr!r$r%r"r#rrnoderrr serialize_all}s$       r,cKst|g|fd|i|S)zx Serialize a representation tree into a YAML stream. If stream is None, return the produced string instead. r)r,)r+rrkwdsrrr r(sr(cCsd}|dkr,| dkrtj}ntj}|j}||||||||| | | || | d }z,|jx|D]}|j|q^W|jWd|jX|r|SdS)z Serialize a sequence of Python objects into a YAML stream. If stream is None, return the produced string instead. N) default_styledefault_flow_stylerrrrrr!r"r#r$r%)rrr&rr'Z representr)r) documentsrrr.r/rrrrrr!r$r%r"r#rrdatarrr dump_alls(      r2cKst|g|fd|i|S)zr Serialize a Python object into a YAML stream. If stream is None, return the produced string instead. r)r2)r1rrr-rrr dumpsr3cKst||fdti|S)z Serialize a sequence of Python objects into a YAML stream. Produce only basic YAML tags. If stream is None, return the produced string instead. r)r2 SafeDumper)r0rr-rrr safe_dump_allsr5cKst|g|fdti|S)z Serialize a Python object into a YAML stream. Produce only basic YAML tags. If stream is None, return the produced string instead. r)r2r4)r1rr-rrr safe_dumpsr6cCs |j||||j|||dS)z Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar. first is a sequence of possible initial characters or None. N)add_implicit_resolver)tagZregexpfirstrrrrr r7sr7cCs |j||||j|||dS)z Add a path based resolver for the given tag. A path is a list of keys that forms a path to a node in the representation tree. Keys can be string values, integers, or None. N)add_path_resolver)r8pathZkindrrrrr r:sr:cCs|j||dS)z Add a constructor for the given tag. Constructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object. N)add_constructor)r8 constructorrrrr r<sr<cCs|j||dS)a  Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object. N)add_multi_constructor)Z tag_prefixZmulti_constructorrrrr r>sr>cCs|j||dS)z Add a representer for the given type. Representer is a function accepting a Dumper instance and an instance of the given data type and producing the corresponding representation node. N)add_representer) data_typeZ representerrrrr r?sr?cCs|j||dS)z Add a representer for the given type. Multi-representer is a function accepting a Dumper instance and an instance of the given data type or subtype and producing the corresponding representation node. N)add_multi_representer)r@Zmulti_representerrrrr rA srAcs eZdZdZfddZZS)YAMLObjectMetaclassz' The metaclass for YAMLObject. csNtt|j|||d|krJ|ddk rJ|jj|j|j|jj||j dS)Nyaml_tag) superrB__init__ yaml_loaderr<rC from_yaml yaml_dumperr?to_yaml)clsnamebasesr-) __class__rr rEszYAMLObjectMetaclass.__init__)__name__ __module__ __qualname____doc__rE __classcell__rr)rMr rBsrBc@s<eZdZdZfZeZeZdZ dZ e ddZ e ddZ dS) YAMLObjectza An object that can dump itself to a YAML stream and load itself from a YAML stream. NcCs |j||S)zC Convert a representation node to a Python object. )Zconstruct_yaml_object)rJrr+rrr rG*szYAMLObject.from_yamlcCs|j|j|||jdS)zC Convert a Python object to a representation node. )Z flow_style)Zrepresent_yaml_objectrCyaml_flow_style)rJrr1rrr rI1s zYAMLObject.to_yaml)rNrOrPrQ __slots__rrFrrHrCrT classmethodrGrIrrrr rSs rS) metaclass)N)N)%errorZtokensrr*rr __version__ZcyamlZ__with_libyaml__ ImportErrorrrr r r r rrrrrrr,r(r2r3r5r6r7r:r<r>r?rAtyperBrSrrrr s^