3 +'\ @sddlmZddlmZddlmZmZmZmZm Z ddl m Z ddl m Z mZmZmZmZmZmZmZmZmZddlmZmZmZddgZGd ddeZGd ddeZd d Zd S))absolute_import) YAMLError)nprintDBG_NODEdbg string_typesnprintf)RegExp) StreamStartEventStreamEndEventMappingStartEventMappingEndEventSequenceStartEventSequenceEndEvent AliasEvent ScalarEventDocumentStartEventDocumentEndEvent) MappingNode ScalarNode SequenceNode SerializerSerializerErrorc@s eZdZdS)rN)__name__ __module__ __qualname__rrq/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-2dxytl9p/ruamel.yaml/ruamel/yaml/serializer.pyrsc@sjeZdZdZedZdddZeddZedd Z d d Z d d Z ddZ ddZ ddZddZdS)rzid%03dzid(?!000$)\d{3,}NcCsz||_|jdk r||j_||_||_||_t|trLttt |j d|_ n||_ ||_ i|_ i|_d|_d|_d|_dS)N.r)dumperZ _serializer use_encodinguse_explicit_startuse_explicit_end isinstancertuplemapintsplit use_versionuse_tagsserialized_nodesanchorslast_anchor_idclosedZ _templated_id)selfencodingZexplicit_startZ explicit_endversiontagsrrrr__init__(s   zSerializer.__init__cCst|jdr|jjS|jjS)Ntyp)hasattrremitterZ_emitter)r.rrrr5Cs zSerializer.emittercCst|jdr|jj|jjS)Nr3)r4rresolverZ _resolver)r.rrrr6Js zSerializer.resolvercCsB|jdkr&|jjt|jdd|_n|jr6tdntddS)N)r/Fzserializer is closedzserializer is already opened)r-r5emitr r r)r.rrropenQs   zSerializer.opencCs2|jdkrtdn|js.|jjtd|_dS)Nzserializer is not openedT)r-rr5r7r )r.rrrclose[s   zSerializer.closecCsttrtd|j|jdkr,tdn|jr:td|jjt|j |j |j d|j ||j |dd|jjt|jdi|_i|_d|_dS)NzSerializing nodeszserializer is not openedzserializer is closed)explicitr0r1)r:r)rrrdumpr-rr5r7rr!r(r) anchor_nodeserialize_noderr"r*r+r,)r.noderrr serializefs    zSerializer.serializec Cs||jkr*|j|dkr|j||j|<nd}y|jjr@|jj}Wn YnX||j|<t|trxL|jD]}|j|qlWn2t|trx&|jD]\}}|j||j|qWdS)N) r+generate_anchoranchorZ always_dumpvaluer#rr<r)r.r>rAitemkeyrBrrrr<{s"       zSerializer.anchor_nodec CsDy |jj}Wnd}YnX|dkr@|jd7_|j|jS|S)N)rArBr,ANCHOR_TEMPLATE)r.r>rArrrr@s   zSerializer.generate_anchorc Csl|j|}||jkr(|jjt|n@d|j|<|jj||t|tr|jj t|j d }|jj t|j d }|j |k|j |k|j j df}|jjt ||j ||j |j|jdnt|tr|j |jj t|j dk}|j}d} d} |jdkr|r|d} |rt|dkr|d} nd} |jjt||j ||j|jdd}x&|j D]} |j| |||d7}qNW|jjt| | gd nt|tr^|j |jj t|j dk}|j}d} d} |jdkr|r|d} |rt|dkr|d} |jjt||j ||j|jt|j d x0|j D]&\} }|j| |d|j||| qW|jjt| | gd |jjdS) NTFztag:yaml.org,2002:)stylecommentr) flow_stylerHrE)rH)rJrHZnr_items)TF)FT)r+r*r5r7rr6Zdescend_resolverr#rresolverBtag startswithrrGrHrrJlenrr=rrr r Zascend_resolver)r.r>parentindexaliasZ detected_tag default_tagZimplicitrHZ end_commentZ seq_commentrCZ map_commentrDrBrrrr=s           zSerializer.serialize_node)NNNNNN)rrrrFr ANCHOR_REr2propertyr5r6r8r9r?r<r@r=rrrrr"s       cCs tjj|S)N)rrSmatch)srrr templated_idsrWN) __future__rZruamel.yaml.errorrZruamel.yaml.compatrrrrrZruamel.yaml.utilr Zruamel.yaml.eventsr r r r rrrrrrZruamel.yaml.nodesrrr__all__robjectrrWrrrrs   0 M