3 +'\"@s:ddlmZmZmZddlZddlZddlZddlZddlm Z ddl Z ddl m Z mZddlTddlTddlTddlmZmZmZmZddlmZmZmZmZddlmZmZmZm Z m!Z!dd l"m#Z#m$Z$dd l%m&Z&m'Z'm(Z(m)Z)dd l*m+Z+m,Z,m-Z-m.Z.dd lmZ/ydd l0m1Z1m2Z2WndZ1Z2YnXe3Z4Gddde3Z5Gddde3Z6ddZ7efddZ8efddZ9efddZ:efddZ;dIddZdLd"d#Z?dMd$d%Z@dNd&d'ZAdedddddfd(d)ZBe rdnd*ZCdedddddeCddddf d+d,ZDdefd-d.ZEdedddddddeCdddddddfd/d0ZFdedddddddeCdddddfd1d2ZGdOd3d4ZHdPd5d6ZIdedddddddeCdddddddfd7d8ZJddde$fd9d:ZKddde$fd;d<ZLde-fd=d>ZMde-fd?d@ZNde(fdAdBZOde(fdCdDZPGdEdFdFeQZRGdGdHdHeeRZSdS)Q)absolute_importunicode_literalsprint_functionN) import_module)UnsafeLoaderWarning YAMLError)*) BaseLoader SafeLoaderLoaderRoundTripLoader) BaseDumper SafeDumperDumperRoundTripDumper)StringIOBytesIOwith_metaclassPY3nprint)VersionedResolverResolver)BaseRepresenterSafeRepresenter RepresenterRoundTripRepresenter)BaseConstructorSafeConstructor ConstructorRoundTripConstructor)r )CParserCEmitterc@s\eZdZeddddfddZeddZeddZed d Zed d Z ed dZ eddZ eddZ eddZ eddZddZefddZddZdedfddZedfdd Zedfd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd=d3d4Zed5d6Zejd7d6Zed8d9Z e jd:d9Z d>d;d<Z!dS)?YAMLNFc Cs.|tk rtdj|jj||dkr(dn||_||_||_d|_g|_ x>|dkrTgn||j D]"}|j t j d}|j jt|q`Wtjjj|_d|_d|_d|_d|_d|_|jdkrd|_tjjj|_tjjj|_tjjj|_tjj j!|_tjj"j#|_$tjj%j&|_&tjj'j(|_)n|jdkr|s6t*dkr@tjjjnt*|_tjjj+|_|sbt,dkrltjj"j$nt,|_$tjj%j&|_&tjj'j-|_)n|jdkrtjjj|_tjjj.|_|st,dkrtjj"j$nt,|_$tjj%j&|_&tjj'j/|_)n|jd kr^|st*dkrtjjjnt*|_tjjj|_|s4t,dkr>tjj"j$nt,|_$tjj%j&|_&tjj'j)|_)nBx@|j D]&}t0|d d|jkrf|j1|PqfWt2d j|jd|_3d|_4d|_5d|_6d|_7d|_8d|_9d |_:d|_;d|_d|_?d|_@d|_Ad|_Bd |_Cd|_Dd|_Ed|_Fd|_Gd|_Hd|_IdS)a _kw: not used, forces keyword arguments in 2.7 (in 3 you can do (*, safe_load=..) typ: 'rt'/None -> RoundTripLoader/RoundTripDumper, (default) 'safe' -> SafeLoader/SafeDumper, 'unsafe' -> normal/unsafe Loader/Dumper 'base' -> baseloader pure: if True only use Python modules input/output: needed to work as context manager plug_ins: a list of plug-in files zL{}.__init__() takes no positional argument but at least one was given ({!r})Nrt.TFsafebaseZunsafetypz1typ "{}"not recognised (need to install plug-in?)rzutf-8)Jenforce TypeErrorformat __class____name__r'pure_output_context_managerplug_insofficial_plug_insreplaceossepappendrruamelyamlresolverrr allow_unicodeReaderScanner Serializerdefault_flow_styleemitterEmitter serializer representerrrscannerZRoundTripScannerparserZRoundTripParserParsercomposerComposer constructorrrr!rr rrrgetattrZinit_typNotImplementedErrorstream canonical old_indentwidth line_break map_indentsequence_indentsequence_dash_offsetcompact_seq_seqcompact_seq_map sort_base_mapping_type_on_outputtop_level_colon_align prefix_colonversionpreserve_quotesallow_duplicate_keysencodingexplicit_start explicit_endtags default_styleZ0top_level_block_style_scalar_no_indent_error_1_1+brace_single_entry_mapping_in_flow_sequence) self_kwr'r-outputr0Zpu file_namemodulerek/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-2dxytl9p/ruamel.yaml/ruamel/yaml/main.py__init__=s                         z YAML.__init__c Cs2y|jStk r,|jd|d|_|jSXdS)N)loader)_readerAttributeErrorr:)r`rererfreaders z YAML.readerc Cs0y|jStk r*|j|d|_|jSXdS)N)rh)_scannerrjr;)r`rererfrBs z YAML.scannercCsjdtjjj}t||s`|jtk r:t|||j|dn&t|dddkrNdSt||t|j t||S)N_)rh_stream) sys _getframef_codeco_namehasattrrDr setattrrHrn)r`attrrererfrCs  z YAML.parsercCs8dtjjj}t||s.t|||j|dt||S)Nrm)rh)rorprqrrrsrtrFrH)r`rurererfrEs z YAML.composercCsHdtjjj}t||s>|j|j|d}|j|_t|||t ||S)Nrm)rXrh) rorprqrrrsrrXrYrtrH)r`ruZcnstrererfrGs   zYAML.constructorcCs<dtjjj}t||s2t|||j|j|dt||S)Nrm)rWrh) rorprqrrrsrtrrWrH)r`rurererfr8s z YAML.resolverc Csdtjjj}t||s|jtk r|jd|j|j|j |j |j |j |j |d }t||||jdk rl|j|_|jdk r~|j|_|jdk r|j|_|jdk r|j|_|jdk r|j|_nt|dddkrdSdSt||S)Nrm)rKindentrMr9rNrVr_dumperrn)rorprqrrrsr?r!rKrLrMr9rNrVr_rtrOZbest_map_indentrPZbest_sequence_indentrQrRrSrH)r`ru_emitterrererfr>s8         z YAML.emitterc CsLdtjjj}t||sBt|||j|j|j|j |j |j |dt ||S)Nrm)rZr[r\rWr]rw) rorprqrrrsrtr<rZr[r\rWr]rH)r`rurererfr@ s  zYAML.serializercCsVdtjjj}t||sL|j|j|j|d}|jdk r@|j|_t |||t ||S)Nrm)r^r=rw) rorprqrrrsrr^r=rTrtrH)r`ruZrepresrererfrA s   zYAML.representerc#Cst|d r2t|dr2|jd }|j|SQRX|j|\}}z|jS|jy|jjWntk rtYnXy|j j Wntk rYnXXdS)a at this point you either have the non-pure Parser (which has its own reader and scanner) or you have the pure Parser. If the pure Parser is set, then set the Reader and Scanner, if not already set. If either the Scanner or Reader are set, you cannot use the non-pure Parser, so reset it to the pure parser and set the Reader resp. Scanner if necessary readopenrbN) rsrzloadget_constructor_parserget_single_datadisposeri reset_readerrjrl reset_scanner)r`rJfprGrCrererfr|<s  z YAML.loadc#cs|tk rtdj|jj|t|d rft|drf|jd$}x|j|tdD] }|VqNWdSQRX|j|\}}zx|j r|j VqxWWd|j y|j j Wntk rYnXy|jjWntk rYnXXdS)NzL{}.__init__() takes no positional argument but at least one was given ({!r})ryrzr)ra)r(r)r*r+r,rsrzload_allr} check_dataget_datarrirrjrlr)r`rJrardrGrCrererfrWs,    z YAML.load_allcsjtk r@jdkr tjjj_jdkr6tjjj_|j_njdk rvjdkr`tjjj_tjj j_|j_npjdk rjdkrtjjj_tjj j_|j_n:j Gfdddjj }|_ ||}||fSj j fS)zM the old cyaml needs special setup, and therefore the stream Ncs"eZdZjdffdd ZdS)z,YAML.get_constructor_parser..XLoaderNcsDtj||||_|_jj||dj|_j|||ddS)N)rh)rWZ loadumper)r rg_parser _composerrrY)selfxrJrWrX)rslvrr`rerfrgs   z5YAML.get_constructor_parser..XLoader.__init__)r, __module__ __qualname__rWrgre)rr`rerfXLoadersr)rDr r:r6r7rkr;rBrJrCrrrnrG)r`rJrrhre)rr`rfr}ws,                 zYAML.get_constructor_parsercCs|jrX|jstd|tk r0tdj|jj||dk rJtdj|jj|jj|n$|dkrhtd|j|g|||dSdS)Nz8Missing output stream while dumping from context managerzJ{}.dump() takes one positional argument but at least two were given ({!r})z?{}.dump() in the context manager cannot have transform keyword zsz"YAML.Xdump_all..r _serializerrx)rsrzrr(r)r*r+r,rUmaxrZrr"get_serializer_representer_emitterr@rA representrjcloser>rdelattrgetvaluedecoder) r`rrJrarrtlcaZfstreamr@rAr>rvalrererf Xdump_allsN           zYAML.Xdump_allcsjtk r@jdkr tjjj_|j_|j_jj jfSjdk rvtjjj_|j_|j_jj jfSj dkrtjj j ntjj j Gfdddtj}|_||jjjjjjjjjjjd }|__|||fS)Nr&cseZdZdfdd ZdS)z8YAML.get_serializer_representer_emitter..XDumperNcsTtj|||||| ||| | | | d ||_|_|_jj|||dj|dS)N) rKrvrMrZr9rNr[r\rWr])r^r=)r!rgrxr _representerr)rrJr^r=rKrvrMr9rNrZr[r\rWr]block_seq_indentrUrV)rr`rerfrgs" zAYAML.get_serializer_representer_emitter..XDumper.__init__)NNNNNNNNNNNNNNN)r,rrrgre)rr`rerfXDumpersr) r^r=rKrvrMr9rNr[r\rWr])r?r!r<r6r7r@r>rJrUrAr'r8Z BaseResolverrrrnr^r=rKrLrMr9rNr[r\rWr]rxr)r`rJrrrwre)rr`rfrs<      )  z'YAML.get_serializer_representer_emittercKs.|jdkr ddlm}|f|Stf|SdS)Nr#r) CommentedMap)r'ruamel.yaml.commentsrdict)r`kwrrererfmapTs   zYAML.mapcGs*|jdkrddlm}||St|SdS)Nr#r) CommentedSeq)r'rrlist)r`argsrrererfseq]s  zYAML.seqcs@tjjt}tjjtjj|fddtj|dD}|S)Ncs g|]}|jdddqS))r2)rr)gpbdrerfrksz*YAML.official_plug_ins..z/*/__plug_in__.py)r3pathdirname__file__glob)r`Zbdresre)rrfr1gs zYAML.official_plug_inscstddjy|jjjWn0tk rVfdd}|jj|YnXy|jjjWn.tk rfdd}|jj|YnXS)z register a class for dumping loading - if it has attribute yaml_tag use that to register, else use class name - if it has methods to_yaml/from_yaml use those to dump/load else dump attributes as mapping yaml_tag!cs|j||jdS)N) flow_style)represent_yaml_objectr=)rAr)clstagrerft_y{sz YAML.register_class..t_ycs |j|S)N)construct_yaml_object)rGnode)rrerff_ysz YAML.register_class..f_y) rHr,rAadd_representerto_yamlrjrGadd_constructor from_yaml)r`rrrre)rrrfregister_classns zYAML.register_classccs|j|\}}zx|jr&|jVqWWd|jy|jjWntk rVYnXy|jjWntk rzYnXXdS)zA Parse a YAML stream and produce parsing events. N) r} check_event get_eventrrirrjrlr)r`rJrmrCrererfparses z YAML.parsecCst||_|S)N)rr/)r`rererf __enter__s zYAML.__enter__cCs"|rtd||jjd|_dS)Nr')rr/r)r`r'value tracebackrererf__exit__s  z YAML.__exit__cCs.|dk r||_|dk r||_|dk r*||_dS)N)rOrPrQ)r`mappingsequenceoffsetrererf_indents z YAML._indentcCs|jS)N)r)r`rererfrvsz YAML.indentcCs ||_dS)N)rL)r`rrererfrvscCs|jS)N)rQ)r`rererfrszYAML.block_seq_indentcCs ||_dS)N)rQ)r`rrererfrscCs||_||_dS)N)rRrS)r`Zseq_seqZseq_maprererfcompactsz YAML.compact)NNN)NN)"r,rrr(rgpropertyrkrBrCrErGr8r>r@rAr|rr}rrrrrrr1rrrrrrvsetterrrrerererfr"<s<i    $   -7S    r"c@s.eZdZd ddZddZddZdd ZdS) rNcCs||_d|_d|_|jj|_||_t|jd rRt|jdrR|j|_|jjd|_|jdk r|j|_|jjdkrzt |_nt |_dS)NFrrzr) _yaml_output_inited _output_pathr. _transformrsrz_fstreamrZrr)r`r7rrererfrgs    zYAMLContextManager.__init__cCs|jr|jjjndSy|jjjWntk r>YnXyt|jdt|jdWntk rrYnX|jr|j j }|jj r|j |jj }|j dkr|j|n$|j j|j||j j|j |_ |jdk r|j jdS)Nrrx)rrr@rr>rrjrrr.rrZrrrflushr)r`rrererfrs.      z"YAMLContextManager.teardown_outputcCsN|jjdkr tdd|D}n|jj}|jj|j||jjjd|_dS)NTcSsg|]}tt|qSre)rr)rrrererfrsz2YAMLContextManager.init_output..)rrUrrr.r@rzr)r`Z first_datarrererf init_outputs   zYAMLContextManager.init_outputc Cs>|js|j|y|jjj|Wntk r8YnXdS)N)rrrrArrj)r`rrererfrs  zYAMLContextManager.dump)N)r,rrrgrrrrerererfrs  rcsfdd}|S)aj decorator for classes that needs to dump/load objects The tag for such objects is taken from the class attribute yaml_tag (or the class name in lowercase in case unavailable) If methods to_yaml and/or from_yaml are available, these are called for dumping resp. loading, default routines (dumping a mapping of the attributes) used otherwise. cstddjyjjjWn0tk rVfdd}jj|YnXyjjjWn.tk rfdd}jj|YnXS)Nrrcs|j||jdS)N)r)rr=)rAr)rrrerfrOsz)yaml_object..yo_deco..t_ycs |j|S)N)r)rGr)rrerfrZsz)yaml_object..yo_deco..f_y) rHr,rArrrjrGrr)rrr)yml)rrrfyo_decoHs zyaml_object..yo_decore)rrre)rrf yaml_object?s rc cs:||}z x|jjr$|jjVq WWd|jjXdS)z9 Scan a YAML stream and produce scanning tokens. N)rBZ check_token get_tokenrr)rJr rhrererfscangs  rc cs:||}z x|jjr$|jjVq WWd|jjXdS)z9 Parse a YAML stream and produce parsing events. N)rrrr)rJr rhrererfrts  rc Cs ||}z|jS|jXdS)zj Parse the first YAML document in a stream and produce the corresponding representation tree. N)Zget_single_noder)rJr rhrererfcomposesrc cs8||}zx|jr"|jjVq WWd|jjXdS)zb Parse all YAML documents in a stream and produce corresponding representation trees. N)Z check_noderZget_noderr)rJr rhrererf compose_alls  rcCs|dkrtjtjtddt}||||d}z |jjS|jjy|j j Wnt k rdYnXy|j j Wnt k rYnXXdS)zd Parse the first YAML document in a stream and produce the corresponding Python object. N) stacklevel)rX)warningswarnrtext UnsafeLoader _constructorr~rrrirrjrlr)rJr rWrXrhrererfr|s  r|ccs|dkrtjtjtddt}||||d}z x|jjrH|jjVq0WWd|jj y|j j Wnt k rzYnXy|j jWnt k rYnXXdS)z\ Parse all YAML documents in a stream and produce corresponding Python objects. Nr)r)rX)rrrrrrrrrrrirrjrlr)rJr rWrXrhrererfrs   rcCs t|t|S)z Parse the first YAML document in a stream and produce the corresponding Python object. Resolve only basic YAML tags. )r|r )rJrWrererf safe_loadsrcCs t|t|S)z~ Parse all YAML documents in a stream and produce corresponding Python objects. Resolve only basic YAML tags. )rr )rJrWrererf safe_load_allsrcCst|t||dS)z Parse the first YAML document in a stream and produce the corresponding Python object. Resolve only basic YAML tags. )rX)r|r )rJrWrXrererfround_trip_loadsrcCst|t||dS)z~ Parse all YAML documents in a stream and produce corresponding Python objects. Resolve only basic YAML tags. )rX)rr )rJrWrXrererfround_trip_load_allsrc Csd}|dkrt}|j}|||||||d} zx|D]} | j| q4WWdy| jjWntk rv| jYnXX|dk r|SdS)zl Emit YAML parsing events into a stream. If stream is None, return the produced string instead. N)rKrvrMr9rN)rremitrxrrj) eventsrJrrKrvrMr9rNrrweventrererfrs* rzutf-8c Csd} |dkr(|dkrt}nt}|j} ||||||||| | | | d }z0|jjx|D]}|j|qXW|jjWdy|jjWnt k r|jYnXX| dk r| SdS)z Serialize a sequence of representation trees into a YAML stream. If stream is None, return the produced string instead. N) rKrvrMr9rNrZrWr]r[r\) rrrrrz serializerrxrrj)ZnodesrJrrKrvrMr9rNrZr[r\rWr]rrwrrererf serialize_all s<  rcKst|g|fd|i|S)zx Serialize a representation tree into a YAML stream. If stream is None, return the produced string instead. r)r)rrJrkwdsrererfrWsrcCsd}|dkr"tdd|dD}|dkrF| dkr:t}nt}|j}||||||||| | | | | ||||d}zN|jjx4|D],}y|jj|Wqtk rYqXqW|jj Wdy|j j Wntk r|j YnXX|dk r|SdS)z Serialize a sequence of Python objects into a YAML stream. If stream is None, return the produced string instead. NTcSsg|]}tt|qSre)rr)rrrererfr{szdump_all..r)r^r=rKrvrMr9rNrZr[r\rWr]rrUrV) rrrrrrzrrrjrrxr)rrJrr^r=rKrvrMr9rNrZr[r\rWr]rrUrVrrwrrererfr`sR   rcCs*t|g||||||||| | | | | ||dS)u Serialize a Python object into a YAML stream. If stream is None, return the produced string instead. default_style ∈ None, '', '"', "'", '|', '>' )rr^r=rKrvrMr9rNrZr[r\rWr]r)r)rrJrr^r=rKrvrMr9rNrZr[r\rWr]rrererfrs"rcKst||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)rr)rrJrrererf safe_dump_allsrcKst|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)rr)rrJrrererf safe_dumpsrcCs>|dkr dn|}t|g||||||||| | | | | ||||dS)NT)rr^r=rKrvrMr9rNrZr[r\rWr]rrUrV)r)rrJrr^r=rKrvrMr9rNrZr[r\rWr]rrUrVrererfround_trip_dumps(rcCs|dkr"|dkr"|j|||dS|rlt|dr@|j|||n,t|tttjjjt frht j|||nt |rt|dr|j|||n,t|t t tjjjtfrt j|||nt 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. Nadd_implicit_resolver)rrs issubclassr r r6r7rhr r rrIr rrwrr)rregexpfirstr rr8rererfrs"   rcCs|dkr"|dkr"|j|||dS|rlt|dr@|j|||n,t|tttjjjt frht j|||nt |rt|dr|j|||n,t|t t tjjjtfrt j|||nt 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. Nadd_path_resolver)rrsrr r r6r7rhr r rrIr rrwrr)rrkindr rr8rererfr<s"  rcCs|dkr|j||n~t|dr0|j||dSt|trHtj||nLt|tr`tj||n4t||rxtj||nt|trt j||nt dS)z Add an object constructor for the given tag. object_onstructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object. Nr) rrsrr rr rrr rrI)rZobject_constructorr rGrererfr[s      rcCs|dkr|j||ndr4t|dr4|j||dSt|trLtj||nRt|trdtj||n:t|tjj j rt j||nt|t rt j||ntdS)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. NFadd_multi_constructor)rrsrr rr rr6r7rhr rr rrI)Z tag_prefixZmulti_constructorr rGrererfrts    rcCs|dkr|j||n~t|dr0|j||dSt|trHtj||nLt|tr`tj||n4t||rxtj||nt|trt j||nt dS)z Add a representer for the given type. object_representer is a function accepting a Dumper instance and an instance of the given data type and producing the corresponding representation node. Nr) rrsrr rrrrrrrI) data_typeZobject_representerrrArererfrs      rcCs|dkr|j||n~t|dr0|j||dSt|trHtj||nLt|tr`tj||n4t||rxtj||nt|trt j||nt 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. Nadd_multi_representer) rrsrr rrrrrrrI)rZmulti_representerrrArererfrs      rcs eZdZdZfddZZS)YAMLObjectMetaclassz' The metaclass for YAMLObject. csNtt|j|||d|krJ|ddk rJ|jj|j|j|jj||j dS)Nr) superrrgyaml_constructorrrryaml_representerrr)rnamebasesr)r+rerfrgszYAMLObjectMetaclass.__init__)r,rr__doc__rg __classcell__rere)r+rfrsrc@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. )r)rrGrrererfrszYAMLObject.from_yamlcCs|j|j|||jdS)zC Convert a Python object to a representation node. )r)rryaml_flow_style)rrArrererfrszYAMLObject.to_yaml)r,rrr  __slots__rrrr rr classmethodrrrerererfrs r)NNN)NNN)N)N)NN)NN)N)N)T __future__rrrror3rr importlibrZ ruamel.yamlr6Zruamel.yaml.errorrrZruamel.yaml.tokensZruamel.yaml.eventsZruamel.yaml.nodesZruamel.yaml.loaderr r r r Zruamel.yaml.dumperr rrrZruamel.yaml.compatrrrrrZruamel.yaml.resolverrrZruamel.yaml.representerrrrrZruamel.yaml.constructorrrrrrZ _ruamel_yamlr r!objectr(r"rrrrrrr|rrrrrrencrrrrrrrrrrrrrtyperrrerererfs  k(      *  8   !