
    "                     6   d dl mZmZmZ d dlZd dlZd dlZd dlZd dlm	Z	 d dl
Zd dlmZmZ d dl d dl d dl d dlmZmZmZmZ d dlmZmZmZmZ d dlmZmZmZm Z m!Z! d d	l"m#Z#m$Z$ d d
l%m&Z&m'Z'm(Z(m)Z) d dl*m+Z+m,Z,m-Z-m.Z. d dlmZ/ 	 	 d dl<m=Z=m>Z>  e?       Z@ G d de?      ZA G d de?      ZBd ZCefdZDefdZEefdZFefdZGd0dZHd0dZId1dZJd1dZKd2dZLd2dZMdedddddfdZNe rdndZOdedddddeOddddfdZPdefd ZQdedddddddeOdddddddfd!ZRdedddddddeOdddddfd"ZSd1d#ZTd1d$ZUdedddddddeOdddddddfd%ZVddde$fd&ZWddde$fd'ZXde-fd(ZYde-fd)ZZde(fd*Z[de(fd+Z\ G d, d-e]      Z^ G d. d/ ee^            Z_y#  dxZ=Z>Y xY w)3    )absolute_importunicode_literalsprint_functionN)import_module)UnsafeLoaderWarning	YAMLError)*)
BaseLoader
SafeLoaderLoaderRoundTripLoader)
BaseDumper
SafeDumperDumperRoundTripDumper)StringIOBytesIOwith_metaclassPY3nprint)VersionedResolverResolver)BaseRepresenterSafeRepresenterRepresenterRoundTripRepresenter)BaseConstructorSafeConstructorConstructorRoundTripConstructor)r   )CParserCEmitterc                      e Zd ZeddddfdZed        Zed        Zed        Zed        Z	ed        Z
ed	        Zed
        Zed        Zed        Zd ZefdZd ZdedfdZedfdZedfdZd Zd Zd Zd Zd Zd Zd Zd Zd!dZed        Zej>                  d        Zed        Z e j>                  d        Z d"d Z!y)#YAMLNFc                 L   |t         ur/t        dj                  | j                  j                  |            |dn|| _        || _        || _        d| _        g | _	        |g n|| j                         z   D ]F  }|j                  t        j                  d      }| j                  j                  t        |             H t         j"                  j$                  j&                  | _        d| _        d| _        d| _        d| _        d| _        | j
                  dk(  r(d| _        t         j"                  j4                  j6                  | _        t         j"                  j8                  j0                  | _        t         j"                  j:                  j<                  | _        t         j"                  j@                  jB                  | _        t         j"                  jD                  jF                  | _$        t         j"                  jJ                  jL                  | _&        t         j"                  jN                  jP                  | _)        nA| j
                  dk(  r|stT        $t         j"                  j4                  j6                  ntT        | _        t         j"                  j:                  jV                  | _        |stX        $t         j"                  jD                  jH                  ntX        | _$        t         j"                  jJ                  jL                  | _&        t         j"                  jN                  jZ                  | _)        nG| j
                  dk(  rt         j"                  j4                  j6                  | _        t         j"                  j:                  j\                  | _        |stX        $t         j"                  jD                  jH                  ntX        | _$        t         j"                  jJ                  jL                  | _&        t         j"                  jN                  j^                  | _)        n[| j
                  d	k(  r|stT        $t         j"                  j4                  j6                  ntT        | _        t         j"                  j:                  j>                  | _        |stX        $t         j"                  jD                  jH                  ntX        | _$        t         j"                  jJ                  jL                  | _&        t         j"                  jN                  jR                  | _)        nb| j                  D ]/  }ta        |d
d      | j
                  k(  s|jc                  |         n% te        dj                  | j
                              d| _3        d| _4        d| _5        d| _6        d| _7        d| _8        d| _9        d| _:        d| _;        d| _<        d| _=        d| _>        d| _?        d| _@        d| _A        d| _B        d| _C        d| _D        d| _E        d| _F        d| _G        d| _H        d| _I        y)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
        L{}.__init__() takes no positional argument but at least one was given ({!r})Nrt.TFsafebaseunsafetypz1typ "{}"not recognised (need to install plug-in?)r   utf-8)Jenforce	TypeErrorformat	__class____name__r,   pure_output_context_managerplug_insofficial_plug_insreplaceossepappendr   ruamelyamlresolverr   r   allow_unicodeReaderScanner
Serializerdefault_flow_styleemitterEmitter
serializerrepresenterr   r   scannerRoundTripScannerparserRoundTripParserParsercomposerComposerconstructorr    r   r"   r   r!   r   r   r   getattrinit_typNotImplementedErrorstream	canonical
old_indentwidth
line_break
map_indentsequence_indentsequence_dash_offsetcompact_seq_seqcompact_seq_map sort_base_mapping_type_on_outputtop_level_colon_alignprefix_colonversionpreserve_quotesallow_duplicate_keysencodingexplicit_startexplicit_endtagsdefault_style0top_level_block_style_scalar_no_indent_error_1_1+brace_single_entry_mapping_in_flow_sequence)	self_kwr,   r3   outputr6   pu	file_namemodules	            #lib/third_party/ruamel/yaml/main.py__init__zYAML.__init__=   s`    g''-vdnn.E.Es'K 
 ;4C	  $!)2x4;Q;Q;SSB

2663/IMM  y!9: T ,,>>!"&88t&+D#!;;..66DL$kk44??DO%{{66KKD!;;..??DL ++,,<<DK"KK0099DM%{{66KKDXX/3x7G##++X L  &{{66FFD7;w&++,,33T[DK"KK0099DM%{{66FFDXX!;;..66DL%{{66FFD7;w&++,,33T[DK"KK0099DM%{{66FFDXX!/3x7G##++X L  &{{66BBD7;w&++,,33T[DK"KK0099DM%{{66BBD--65$/488;OOD) (
 *GNNtxxX  
#$%!##04-%)" #$)!" 	!@E=;@8    c                     	 | j                   S # t        $ r' | j                  d |       | _         | j                   cY S w xY wNloader)_readerAttributeErrorr@   rj   s    rp   readerzYAML.reader   s>    	 << 	 ;;tD;9DL<<	 s    ->>c                     	 | j                   S # t        $ r& | j                  |       | _         | j                   cY S w xY wrt   )_scannerrx   rA   ry   s    rp   rH   zYAML.scanner   s<    	!==  	! LLL5DM== 	!s    ,==c                 D   dt        j                         j                  j                  z   }t	        | |      s^| j
                  t        urt        | || j                  |              n.t        | dd       y t        | |t        | j                               t        | |      S )N_ru   _stream)
sys	_getframef_codeco_namehasattrrL   r!   setattrrP   r   rj   attrs     rp   rJ   zYAML.parser   s     S]]_++333tT"{{')dDKKtK$<=4D19 D$(=> tT""rr   c                     dt        j                         j                  j                  z   }t	        | |      st        | || j                  |              t        | |      S )Nr~   ru   )r   r   r   r   r   r   rN   rP   r   s     rp   rM   zYAML.composer   sN     S]]_++333tT"D$T :;tT""rr   c                     dt        j                         j                  j                  z   }t	        | |      s;| j                  | j                  |       }| j                  |_        t        | ||       t        | |      S )Nr~   )ra   rv   )
r   r   r   r   r   r   ra   rb   r   rP   )rj   r   cnsts      rp   rO   zYAML.constructor   sm     S]]_++333tT"##D4H4HQU#VD(,(A(AD%D$%tT""rr   c                     dt        j                         j                  j                  z   }t	        | |      s(t        | || j                  | j                  |              t        | |      S )Nr~   )r`   rv   )	r   r   r   r   r   r   r   r`   rP   r   s     rp   r>   zYAML.resolver   sT     S]]_++333tT"D$dll4 PQtT""rr   c                    dt        j                         j                  j                  z   }t	        | |      s | j
                  t        ur| j                  d | j                  | j                  | j                  | j                  | j                  | j                  | j                  | 	      }t        | ||       | j                  | j                  |_        | j"                  | j"                  |_        | j&                  | j&                  |_        | j(                  | j(                  |_        | j*                  !| j*                  |_        nt-        | dd       y y t-        | |      S )Nr~   )rT   indentrV   r?   rW   r_   ri   dumperr   )r   r   r   r   r   rE   r"   rT   rU   rV   r?   rW   r_   ri   r   rX   best_map_indentrY   best_sequence_indentrZ   r[   r\   rP   )rj   r   _emitters      rp   rD   zYAML.emitter   s4    S]]_++333tT"||8+<<"nn??**"&"4"4#!%!2!2@D@p@p ( 
 dH-??./3H,''3484H4HH1,,8484M4MH1''3/3/C/CH,''3/3/C/CH,4D19tT""rr   c                 0   dt        j                         j                  j                  z   }t	        | |      sTt        | || j                  | j                  | j                  | j                  | j                  | j                  |              t        | |      S )Nr~   )rc   rd   re   r`   rf   r   )r   r   r   r   r   r   rB   rc   rd   re   r`   rf   rP   r   s     rp   rF   zYAML.serializer  s     S]]_++333tT"!]]#'#6#6!%!2!2 LL    tT""rr   c                 ,   dt        j                         j                  j                  z   }t	        | |      sR| j                  | j                  | j                  |       }| j                  | j                  |_        t        | ||       t        | |      S )Nr~   )rg   rC   r   )r   r   r   r   r   r   rg   rC   r]   r   rP   )rj   r   repress      rp   rG   zYAML.representer   s     S]]_++333tT"%%"00#'#:#: & F
 44@:>:_:_7D$'tT""rr   c                    t        |d      s8t        |d      r,|j                  d      5 }| j                  |      cddd       S | j                  |      \  }}	 |j	                         |j                          	 | j                  j                          	 | j                  j                          S # 1 sw Y   txY w# t        $ r Y 3w xY w# t        $ r Y S w xY w# |j                          	 | j                  j                          n# t        $ r Y nw xY w	 | j                  j                          w # t        $ r Y w w xY wxY w)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
        readopenrbN)r   r   loadget_constructor_parserget_single_datadisposerw   reset_readerrx   r|   reset_scanner)rj   rS   fprO   rJ   s        rp   r   z	YAML.load<  s    vv&766+BT"byy} #""99&AV	..0NN))+++- #" "  "  NN))+! ++-! s   B0C :B<C0B9<	CC	CCE,DE	DEDED21E2	D>;E=D>>Ec              #   f  K   |t         ur/t        dj                  | j                  j                  |            t        |d      sHt        |d      r<|j                  d      5 }| j                  |t               D ]  }|  	 d d d        y | j                  |      \  }}	 |j                         r#|j                          |j                         r#|j                          	 | j                  j                          	 | j                  j!                          y # 1 sw Y   xY w# t        $ r Y 3w xY w# t        $ r Y y w xY w# |j                          	 | j                  j                          n# t        $ r Y nw xY w	 | j                  j!                          w # t        $ r Y w w xY wxY ww)Nr&   r   r   r)rk   )r.   r/   r0   r1   r2   r   r   load_allr   
check_dataget_datar   rw   r   rx   r|   r   )rj   rS   rk   r   drO   rJ   s          rp   r   zYAML.load_allW  s    g''-vdnn.E.Es'K  vv&766+BS!Rrw7AG 8 "! #99&AV	((*!**,, ((* NN))+++-' "!  "  "  NN))+! ++-! s   A!F1#"DF1#2E F1'D) D8 F1D&"F1)	D52F14D55F18	EF1EF1F.E43F.4	F =F.?F  F.FF.	F+(F.*F++F..F1c                      j                   t        ur} j                  )t        j                  j
                  j                   _         j                  )t        j                  j                  j                   _        | j
                  _        n; j                  p j                  )t        j                  j                  j                   _        t        j                  j                  j                    _         | j
                  _        n j                  p j                  )t        j                  j
                  j                   _        t        j                  j                  j                    _         | j
                  _        nC j                   G  fdd j                    j                        }| _         ||      }||fS  j                   j                  fS )zM
        the old cyaml needs special setup, and therefore the stream
        c                   6    e Zd ZW j                  df fd	Zy),YAML.get_constructor_parser.<locals>.XLoaderNc                     t        j                  | |       | x| _        | _        j                  j                  | |        j
                  | _        j                  | ||        y )Nru   )r`   	loadumper)r!   rq   _parser	_composerr   rb   )selfxrS   r`   ra   rslvrrj   s       rp   rq   z5YAML.get_constructor_parser.<locals>.XLoader.__init__  sZ    ((7:??((11%1F595N5N2ugOrr   )r2   
__module____qualname__r`   rq   r   rj   s   rp   XLoaderr     s    8<VZ Prr   r   )rL   r!   r@   r<   r=   rz   rA   rH   rS   rJ   r   r   r   rO   )rj   rS   r   rv   r   s   `   @rp   r   zYAML.get_constructor_parserw  sS   
 ;;g%{{"$kk0077||#%{{22::!'DKK{{&<<'#);;#6#6#>#>DL$kk0077%+");;&"(++"4"4";";DK$kk0077%+" Pdkk4+;+;U P  & v~%,,rr   c                    | j                   r| j                  st        d      |t        ur/t        dj	                  | j
                  j                  |            |.t        dj	                  | j
                  j                              | j                   j                  |       y |t        d      | j                  |g|||      S )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 z<Need a stream argument when not dumping from context manager	transform)	r5   r4   r/   r.   r0   r1   r2   dumpdump_all)rj   datarS   rk   r   s        rp   r   z	YAML.dump  s      << Z[['!,,2F4>>3J3JC,P  $vdnn556  !!&&t,~ ^__==$	=JJrr   c                 \   | j                   rt        |t        ur/t        dj	                  | j
                  j                  |            || _        t        | |      | _         |D ]  }| j                   j                  |        | j                   j                          d | _        d | _         y )NP{}.dump(_all) takes two positional argument but at least three were given ({!r})r   )r5   rR   r.   r/   r0   r1   r2   r4   YAMLContextManagerr   teardown_output)rj   	documentsrS   rk   r   r   s         rp   r   zYAML.dump_all  s      %%g**0&1H1H#*N   249 MD!!&&t, --/ $rr   c           
         t        |d      s<t        |d      r0|j                  d      5 }| j                  ||||      cddd       S |t        ur/t	        dj                  | j                  j                  |            | j                  du r/t        |d   D cg c]  }t        t        |             c}      }n| j                  }|#|}| j                  t               }n
t               }| j                  ||      \  }	}
}	 | j                   j                          |D ]  }	 | j"                  j%                  |         | j                   j)                          	 | j*                  j-                          t/        | d	       t/        | d
       |rY|j1                         }| j                  r|j3                  | j                        }	 ||       y|j5                   ||             y# 1 sw Y   xY wc c}w # t&        $ r  w xY w# t&        $ r  w xY w# 	 | j*                  j-                          n# t&        $ r  w xY wt/        | d	       t/        | d
       w xY w)zL
        Serialize a sequence of Python objects into a YAML stream.
        writer   wr   Nr   Tr   _serializerr   )r   r   r   r.   r/   r0   r1   r2   r^   maxlenstrrc   r   r   "get_serializer_representer_emitterrF   rG   	representrx   closerD   r   delattrgetvaluedecoder   )rj   r   rS   rk   r   r   xtlcafstreamrF   rG   rD   r   vals                 rp   	Xdump_allzYAML.Xdump_all  s&   
 vw'GFF,CS!R}}YC9}M "!g**0&1H1H#*N 
 %%-Yq\:\CF\:;D--D G}}$! +/+R+RD,
(
K	&OO  "!$$..t4 " OO!!#$$& D-(D*%//#C}}jj/#  in-] "! ;" &  " $$&!  D-(D*%sY   G+G8H %G= H H +G5=HH HIH65I6IIc                 4     j                   t        urz j                  )t        j                  j
                  j                   _        | j                  _        | j                  _         j
                   j                   j                  fS  j                  nt        j                  j                  j                    _         | j                  _        | j                  _         j
                   j                   j                  fS  j                  dk(  r$t        j                  j                  j                  n#t        j                  j                  j                   G  fddt         j                        }| _         || j                    j"                   j$                   j&                   j(                   j*                   j,                   j.                   j0                   j2                   j4                        }|x _         _        |||fS )Nr*   c                   :    e Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fd	Zy)8YAML.get_serializer_representer_emitter.<locals>.XDumperNc                     t        j                  | |||||	|||
|||       | x| _        x| _        | _        j
                  j                  | ||       j                  |        y )N)
rT   r   rV   rc   r?   rW   rd   re   r`   rf   )rg   rC   )r"   rq   r   r   _representerr   )r   rS   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   block_seq_indentr^   r_   r   rj   s                    rp   rq   zAYAML.get_serializer_representer_emitter.<locals>.XDumper.__init__  s    ( !!'!%"/)#1!-# KPOO!2U5G  ))K] *  u%rr   )NNNNNNNNNNNNNNN)r2   r   r   rq   r   s   rp   XDumperr     s7     ##'"#!!%&*!#&&rr   r   )rg   rC   rT   r   rV   r?   rW   rd   re   r`   rf   )rE   r"   rB   r<   r=   rF   rD   rS   r^   rG   r,   r>   BaseResolverr   r   r   rg   rC   rT   rU   rV   r?   rW   rd   re   r`   rf   r   r   )rj   rS   r   r   r   r   s   `    @rp   r   z'YAML.get_serializer_representer_emitter  s    <<x'&"(++"8"8"C"C"(DLL15DLL.??D$4$4dllBB??&!;;..66DL"(DLL15DLL.??D$4$4dllBB
 xx6! KK  --%%.. 	'	&h 0 0% '	&R ,,#66nn??**,,..**LL
 ,21(vv%%rr   c                 R    | j                   dk(  rddlm}  |di |S t        di |S )Nr'   r   )CommentedMap )r,   ruamel.yaml.commentsr   dict)rj   kwr   s      rp   mapzYAML.mapT  s+    88t9%"%%:":rr   c                 F    | j                   dk(  rddlm}  || S t        | S )Nr'   r   )CommentedSeq)r,   r   r   list)rj   argsr   s      rp   seqzYAML.seq]  s&    88t9&&;rr   c                 >   t         j                  j                  t              }t         j                  j                  t         j                  j                  |            }t	        j                  |dz         D cg c]  }|j                  |d      dd  }}|S c c}w )Nz/*/__plug_in__.py    )r9   pathdirname__file__globr8   )rj   bdgpbdr   ress        rp   r7   zYAML.official_plug_insg  su    WW__X&wwrwwr2326))BAT<T2UV2UQqyyr"1R(2UV
 Ws   :Bc                    t        ddj                  z         	 | j                  j                  j                         	 | j                  j                  j                         S # t
        $ r% fd}| j                  j                  |       Y Vw xY w# t
        $ r% fd}| j                  j                  |       Y S w xY w)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!c                 B    | j                  || j                        S N
flow_stylerepresent_yaml_objectrC   rG   r   clstags     rp   t_yz YAML.register_class.<locals>.t_y{  *    "88s{/M/M 9  rr   c                 (    | j                  |      S Nconstruct_yaml_objectrO   noder   s     rp   f_yz YAML.register_class.<locals>.f_y      "88sCCrr   	rP   r2   rG   add_representerto_yamlrx   rO   add_constructor	from_yaml)rj   r   r   r  r   s    `  @rp   register_classzYAML.register_classn  s     c:sS\\'9:
	7,,S#++>	7,,S#--@ 
%  	7 ,,S#6	7  	7D ,,S#6
	7s#   &A- &B -+BB*CCc              #   8  K   | j                  |      \  }}	 |j                         r#|j                          |j                         r#|j                          	 | j                  j                          	 | j                  j                          y# t        $ r Y 'w xY w# t        $ r Y yw xY w# |j                          	 | j                  j                          n# t        $ r Y nw xY w	 | j                  j                          w # t        $ r Y w w xY wxY ww)zA
        Parse a YAML stream and produce parsing events.
        N)	r   check_event	get_eventr   rw   r   rx   r|   r   )rj   rS   r~   rJ   s       rp   parsez
YAML.parse  s     
 //7	6	$$&&&(( $$& NN))+++- "  "  NN))+! ++-! s   D2B0 DB 7B! D	BDBD!	B-*D,B--D0DCD	C)&D(C))D-DD	DDDDDc                 &    t        |       | _        | S r   )r   r5   ry   s    rp   	__enter__zYAML.__enter__  s     24 8rr   c                 b    |rt        d|       | j                  j                          d | _        y )Nr,   )r   r5   r   )rj   r,   value	tracebacks       rp   __exit__zYAML.__exit__  s)    5#--/ $rr   c                 <    ||| _         ||| _        ||| _        y y r   )rX   rY   rZ   )rj   mappingsequenceoffsets       rp   _indentzYAML._indent  s0    %DO#+D (.D% rr   c                     | j                   S r   )r  ry   s    rp   r   zYAML.indent  s     ||rr   c                     || _         y r   )rU   rj   r   s     rp   r   zYAML.indent  s     rr   c                     | j                   S r   rZ   ry   s    rp   r   zYAML.block_seq_indent  s     (((rr   c                     || _         y r   r  r  s     rp   r   zYAML.block_seq_indent  s     %(!rr   c                      || _         || _        y r   )r[   r\   )rj   seq_seqseq_maps      rp   compactzYAML.compact  s    &&rr   NNNNN)"r2   r   r   r.   rq   propertyrz   rH   rJ   rM   rO   r>   rD   rF   rG   r   r   r   r   r   r   r   r   r   r7   r
  r  r  r  r  r   setterr   r#  r   rr   rp   r$   r$   <   s   t%thAT     ! ! # #* # # # # # # !# !#F # #$ # #66 $+ @+-Z !%'T K* /6 %" 07$ 5nP&f>,
%/   ]]  ) ) ( ('rr   r$   c                   &    e Zd ZddZd Zd Zd Zy)r   Nc                    || _         d| _        d | _        | j                   j                  | _        || _        t        | j                  d      sGt        | j                  d      r1| j                  | _        | j                  j                  d      | _        | j                  G| j                  | _        | j                   j                  t               | _        y t               | _        y y )NFr   r   r   )_yaml_output_inited_output_pathr4   
_transformr   r   _fstreamrc   r   r   )rj   r=   r   s      rp   rq   zYAMLContextManager.__init__  s    
# zz))# t||W-'$,,2O $D,,11#6DL ??& LLDMzz""*'z&y 'rr   c                 :   | j                   r%| j                  j                  j                          ny 	 | j                  j                  j                          	 t        | j                  d       t        | j                  d       | j                  r| j                  j                         }| j                  j                  r%|j                  | j                  j                        }| j                  | j                  |       nU| j                  j                  | j                  |             | j                  j                          | j                  | _	        | j                   | j                  j                          y y # t        $ r  w xY w# t        $ r  w xY w)Nr   r   )r+  r*  rF   r   rD   r   rx   r   r-  r4   r   rc   r   r.  r   flushr,  r  s     rp   r   z"YAMLContextManager.teardown_output  s4   JJ!!'')	JJ&&(	DJJ.DJJ
+ ??,,'')Czz""jj!4!45}}$$##DOOC$89##%#}}(LL  )%  		  		s   $F ,F FFc           
      d   | j                   j                  du r,t        |D cg c]  }t        t	        |             c}      }n| j                   j                  }| j                   j                  | j                  |       | j                   j                  j                          d| _	        y c c}w )NT)
r*  r^   r   r   r   r   r4   rF   r   r+  )rj   
first_datar   r   s       rp   init_outputzYAMLContextManager.init_output  s    ::++t3Z8ZCFZ89D::33D

55dllDI

""$" 9s   B-c                     | j                   s| j                  |       	 | j                  j                  j	                  |       y # t
        $ r  w xY wr   )r+  r3  r*  rG   r   rx   )rj   r   s     rp   r   zYAMLContextManager.dump  sH    ""T"	JJ"",,T2 		s   %A Ar   )r2   r   r   rq   r   r3  r   r   rr   rp   r   r     s    )@!:#rr   r   c                       fd}|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.
    c                     t         dd j                  z         	 j                  j                    j                         	 j                  j                   j                          S # t
        $ r%  fd}j                  j                   |       Y Vw xY w# t
        $ r%  fd}j                  j                  |       Y  S w xY w)Nr   r   c                 B    | j                  || j                        S r   r   r   s     rp   r   z)yaml_object.<locals>.yo_deco.<locals>.t_yO  r   rr   c                 (    | j                  |      S r   r   r  s     rp   r  z)yaml_object.<locals>.yo_deco.<locals>.f_yZ  r  rr   r  )r   r   r  r   ymls   `  @rp   yo_decozyaml_object.<locals>.yo_decoH  s    c:sS\\'9:
	6OO++C=	6OO++C? 
%  	6 OO++C5	6  	6D OO++C5
	6s#   &A. &B .+BB*CCr   )r9  r:  s   ` rp   yaml_objectr;  ?  s    2 Nrr   c              #   2  K    ||       }	 |j                   j                         r7|j                   j                          |j                   j                         r7|j                  j	                          y# |j                  j	                          w xY ww)z9
    Scan a YAML stream and produce scanning tokens.
    N)rH   check_token	get_tokenr   r   rS   r   rv   s      rp   scanr@  g  m     
 F^F!nn((*..**,, nn((* 	     	BAA8 B8BBc              #   2  K    ||       }	 |j                   j                         r7|j                   j                          |j                   j                         r7|j                   j                          y# |j                   j                          w xY ww)z9
    Parse a YAML stream and produce parsing events.
    N)r   r  r  r   r?  s      rp   r  r  t  rA  rB  c                 ~     ||       }	 |j                         |j                          S # |j                          w xY w)zj
    Parse the first YAML document in a stream
    and produce the corresponding representation tree.
    )get_single_noder   r?  s      rp   composerF    s3     F^F%%'s   * <c              #   
  K    ||       }	 |j                         r-|j                  j                          |j                         r-|j                  j	                          y# |j                  j	                          w xY ww)zb
    Parse all YAML documents in a stream
    and produce corresponding representation trees.
    N)
check_noder   get_noder   r   r?  s      rp   compose_allrJ    sg      F^F!!""++-- ! 	  s   	B<A$ 	B$B  Bc                 v   |0t        j                  t        j                  t        d       t        } || ||      }	 |j
                  j                         |j                  j                          	 |j                  j                          	 |j                  j                          S # t        $ r Y 'w xY w# t        $ r Y S w xY w# |j                  j                          	 |j                  j                          n# t        $ r Y nw xY w	 |j                  j                          w # t        $ r Y w w xY wxY w)zd
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
       
stacklevelra   )warningswarnr   textUnsafeLoader_constructorr   r   r   rw   r   rx   r|   r   rS   r   r`   ra   rv   s        rp   r   r     s    ~)..0CPQRFG_EF""224 	NN'')	OO))+  		  		 	 	NN'') 			OO))+ 		sw   C 3B)B8)	B54B58	CCD8#C>=D8>	D
D8	D

D8D)(D8)	D52D84D55D8c              #     K   |0t        j                  t        j                  t        d       t        } || ||      }	 |j
                  j                         r7|j
                  j                          |j
                  j                         r7|j                  j                          	 |j                  j                          	 |j                  j                          y# t        $ r Y 'w xY w# t        $ r Y yw xY w# |j                  j                          	 |j                  j                          n# t        $ r Y nw xY w	 |j                  j                          w # t        $ r Y w w xY wxY ww)z\
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    NrL  rM  rO  )rP  rQ  r   rR  rS  rT  r   r   r   r   rw   r   rx   r|   r   rU  s        rp   r   r     s;     ~)..0CPQRFG_EF!!,,.%%..00 !!,,. 	 	NN'')	OO))+  		  		 	 	NN'') 			OO))+ 		s   >E5AD E5-C# C2 "E5#	C/,E5.C//E52	C>;E5=C>>E5E2D87E28	EE2EE2E#"E2#	E/,E2.E//E22E5c                 $    t        | t        |      S )
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    Resolve only basic YAML tags.
    )r   r   rS   r`   s     rp   	safe_loadrZ    s     
G,,rr   c                 $    t        | t        |      S )~
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    Resolve only basic YAML tags.
    )r   r   rY  s     rp   safe_load_allr]    s     FJ00rr   c                 (    t        | t        ||      S )rX  rO  )r   r   rS   r`   ra   s      rp   round_trip_loadr`    s     /RRrr   c                 (    t        | t        ||      S )r\  rO  )r   r   r_  s      rp   round_trip_load_allrb    s     FOWoVVrr   c                 H   d}|t               }|j                  } |||||||      }		 | D ]  }
|	j                  |
        	 	 |	j                  j	                          | |       S y# t
        $ r  w xY w# 	 |	j                  j	                          w # t
        $ r  w xY wxY w)zl
    Emit YAML parsing events into a stream.
    If stream is None, return the produced string instead.
    N)rT   r   rV   r?   rW   )r   r   emitr   r   rx   )eventsrS   r   rT   r   rV   r?   rW   r   r   events              rp   rd  rd    s     H~??#FEKK 	OO##% z   			OO##% 		s/   A6 A( (A36B!8BB!BB!r-   c                    d}|#|t               }n
t               }|j                  } |||||||||||	|
      }	 |j                  j	                          | D ]  }|j                  |        |j                  j                          	 |j                  j                          | |       S y# t        $ r  w xY w# 	 |j                  j                          w # t        $ r  w xY wxY w)z
    Serialize a sequence of representation trees into a YAML stream.
    If stream is None, return the produced string instead.
    N)
rT   r   rV   r?   rW   rc   r`   rf   rd   re   )
r   r   r   r   r   	serializer   r   r   rx   )nodesrS   r   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r   r  s                   rp   serialize_allrj     s    ( H~ZFYF??#%!F
!DT"   "	OO##% z   			OO##% 		s0   AB; 	B- -B8;C&=CC&C##C&c                 "    t        | g|fd|i|S )zx
    Serialize a representation tree into a YAML stream.
    If stream is None, return the produced string instead.
    r   )rj  )r  rS   r   kwdss       rp   rh  rh  W  s     $??$??rr   c                 z   d}|du r.t        | d   D cg c]  }t        t        |             c}      }|#|
t               }n
t	               }|j
                  } ||f|||||||	|
|||||||d}	 |j                  j                          | D ]  }	 |j                  j                  |         |j                  j                          	 |j                  j                          | |       S yc c}w # t        $ r  w xY w# t        $ r  w xY w# 	 |j                  j                          w # t        $ r  w xY wxY w)z
    Serialize a sequence of Python objects into a YAML stream.
    If stream is None, return the produced string instead.
    NTr   )rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r^   r_   )r   r   r   r   r   r   r   r   r   r   rx   r   r   r   )r   rS   r   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r^   r_   r   r   r   r   s                         rp   r   r   `  sc   2 H$ #)A,$G,QSQ[,$G H~ZFYF??#-#%!)3!!F$!D##--d3  	  "	OO##% zU %H< "   			OO##% 		sM   C.2D C3-D 
D 3C>>D DD:D,+D:,D77D:c                 :    t        | g|||||||||	|
|||||      S )u   
    Serialize a Python object into a YAML stream.
    If stream is None, return the produced string instead.

    default_style ∈ None, '', '"', "'", '|', '>'

    )r   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r   )r   rS   r   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   s                   rp   r   r     sC    4 	#-#%!)! rr   c                 (    t        | |fdt        i|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   r   r   )r   rS   rl  s      rp   safe_dump_allrr    s     IvAjADAArr   c                 *    t        | g|fdt        i|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   rq  )r   rS   rl  s      rp   	safe_dumprt    s     TFF>:>>>rr   c                     |dn|}t        | g|fi d|d|d|d|d|d|d|d	|	d
|
d|d|d|d|d|d|d|S )NTr   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r^   r_   ro  )r   rS   r   rg   rC   rT   r   rV   r?   rW   rc   rd   re   r`   rf   r   r^   r_   s                     rp   round_trip_dumprv    s    * *1D}M	  $	
 .    $   & "    *!" 4#$ "% rr   c                 0   |||j                  | ||       y|r}t        |d      r |j                   | ||       n\t        |t        t        t
        j                  j                  j                  t        f      rt        j                   | ||       nt        |r}t        |d      r |j                   | ||       yt        |t        t        t
        j                  j                  j                  t         f      rt        j                   | ||       yt        y)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)rx  r   
issubclassr
   r   r<   r=   rv   r   r   r   rR   r   r   r   r   r   )r   regexpfirstr   r   r>   s         rp   rx  rx    s     ~&.&&sFE:623(F((fe<ZV[[-?-?-F-FX
 **3>%%623(F((fe<ZV[[-?-?-F-FX
 **3>%% rr   c                 0   |||j                  | ||       y|r}t        |d      r |j                   | ||       n\t        |t        t        t
        j                  j                  j                  t        f      rt        j                   | ||       nt        |r}t        |d      r |j                   | ||       yt        |t        t        t
        j                  j                  j                  t         f      rt        j                   | ||       yt        y)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)r}  r   ry  r
   r   r<   r=   rv   r   r   r   rR   r   r   r   r   r   )r   r   kindr   r   r>   s         rp   r}  r}  <  s     ~&.""3d36./$F$$S$5ZV[[-?-?-F-FX
 &&sD$7%%6./$F$$S$5ZV[[-?-?-F-FX
 &&sD$7%% rr   c                    ||j                  | |       yt        |d      r |j                   | |       yt        |t              rt	        j                   | |       yt        |t
              rt        j                   | |       yt        ||      rt        j                   | |       yt        |t              rt        j                   | |       yt        )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  )r  r   ry  r
   r   r   r   r   r   r    rR   )r   object_constructorr   rO   s       rp   r  r  [  s     ~##C);<6,-"F""3(:;fj)++C1CD
+++C1CD'''-?@0 006HI%%rr   c                    ||j                  | |       y	 t        |t              rt	        j                   | |       yt        |t
              rt        j                   | |       yt        |t        j                  j                  j                        rt        j                   | |       yt        |t              rt        j                   | |       yt        )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_constructorr   ry  r
   r   r   r   r<   r=   rv   r   r   r   r    rR   )
tag_prefixmulti_constructorr   rO   s       rp   r  r  t  s     ~))*6GH fj)11*>OP
+11*>OP 2 2 9 9:--j:KL0 66zCTU%%rr   c                    ||j                  | |       yt        |d      r |j                   | |       yt        |t              rt	        j                   | |       yt        |t
              rt        j                   | |       yt        ||      rt        j                   | |       yt        |t              rt        j                   | |       yt        )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  )r  r   ry  r   r   r   r   r   r   r   rR   )	data_typeobject_representerr   rG   s       rp   r  r    s     ~##I/AB6,-"F""9.@Afj)++I7IJ
+++I7IJ'''	3EF0 00<NO%%rr   c                    ||j                  | |       yt        |d      r |j                   | |       yt        |t              rt	        j                   | |       yt        |t
              rt        j                   | |       yt        ||      rt        j                   | |       yt        |t              rt        j                   | |       yt        )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  r   ry  r   r   r   r   r   r   r   rR   )r  multi_representerr   rG   s       rp   r  r    s     ~)))5FG623(F((4EFfj)11)=NO
+11)=NO'--i9JK0 66yBST%%rr   c                   "     e Zd ZdZ fdZ xZS )YAMLObjectMetaclassz'
    The metaclass for YAMLObject.
    c                     t         t        |   |||       d|v r]|d   W| j                  j	                  | j
                  | j                         | j                  j                  | | j                         y y y )Nr   )
superr  rq   yaml_constructorr  r   r	  yaml_representerr  r  )r   namebasesrl  r1   s       rp   rq   zYAMLObjectMetaclass.__init__  si    !30udC$z"2">  00s}}M  00ckkB #?rr   )r2   r   r   __doc__rq   __classcell__)r1   s   @rp   r  r    s    C Crr   r  c                   D    e Zd ZdZdZeZeZdZ	dZ
ed        Zed        Zy)
YAMLObjectza
    An object that can dump itself to a YAML stream
    and load itself from a YAML stream.
    r   Nc                 &    |j                  ||       S )zC
        Convert a representation node to a Python object.
        r   )r   rO   r  s      rp   r	  zYAMLObject.from_yaml  s     00s;;rr   c                 T    |j                  | j                  || | j                        S )zC
        Convert a Python object to a representation node.
        r   )r   r   yaml_flow_style)r   rG   r   s      rp   r  zYAMLObject.to_yaml  s/     00LL$0C0C 1 
 	
rr   )r2   r   r   r  	__slots__r   r  r   r  r   r  classmethodr	  r  r   rr   rp   r  r    sJ    
 I""HO< < 
 
rr   r  r$  r   r%  )`
__future__r   r   r   r   r9   rP  r   	importlibr   ruamel.yamlr<   ruamel.yaml.errorr   r   ruamel.yaml.tokensruamel.yaml.eventsruamel.yaml.nodesruamel.yaml.loaderr
   r   r   r   ruamel.yaml.dumperr   r   r   r   ruamel.yaml.compatr   r   r   r   r   ruamel.yaml.resolverr   r   ruamel.yaml.representerr   r   r   r   ruamel.yaml.constructorr   r   r   r    rS  typingListSetDictUnionAnyCallable
StreamTypeStreamTextTypeVersionTypepathlibPath_ruamel_yamlr!   r"   objectr.   r$   r   r;  r@  r  rF  rJ  r   r   rZ  r]  r`  rb  rd  encrj  rh  r   r   rr  rt  rv  rx  r}  r  r  r  r  typer  r  r   rr   rp   <module>r     s}   I H 
 	   #  <      N N N N M M <   6. (U
'6 U
'pP PV"P  
!   
! " 
  & !02-1SW 
%P dw
 
	4n   @ 
	%ET 
	!+\B? 
	%)b D&D '+4x &> 59k &2 AER] &4 ;?K &6 @DQ\ &4
C$ 
C
 34 
A-Ghs   
F F