
    h              	          S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJrJ	r	J
r
JrJrJr  SSKJr  S\S\4S jrS\S\4S jrS\S\4S	 jrS\S
\\   S\4S jrS\S
\\   S\4S jrS\\\4   S
\\   S\4S jr  SS\\\4   S\\   S\S\4S jjr SS\
\   S\\   S\\\4   4S jjrS\S\S\\\4   4S jrS\S\\\4   4S jrS\S\\\4   4S jrS S jr\S:X  a  \" 5         gg)!    N)DictIterableListOptionalSetTuple   )read_data_filedatareturnc                 X    SnX;  a  SU-   U -   U-   $ SU ;  a  SU -   S-   $ [        U 5      $ )Nz'''rz"""zr""")repr)r   triplequotes     =/usr/lib/python3/dist-packages/cockpit/_vendor/bei/beipack.pyescape_stringr      sC    K[ 4'+55D}u$$:    c                 <    S[        U R                  S5      5      -   $ )Nbasciir   decoder   s    r   ascii_bytes_reprr   (   s    t{{73444r   c                 <    [        U R                  S5      5      S-   $ )Nutf-8z.encode('utf-8')r   r   s    r   utf8_bytes_reprr   ,   s    W-.1CCCr   importsc                     UR                  S5        [        R                  " U 5      R                  S5      R	                  5       nSU S3$ )Nzfrom binascii import a2b_base64r   za2b_base64("z"))addbinascii
b2a_base64r   strip)r   r   encodeds      r   base64_bytes_reprr%   0   sD     KK12!!$'..w7==?G'"%%r   c                      [        U 5      $ ! [         a     Of = f [        U 5      $ ! [         a     Of = f[        X5      $ N)r   UnicodeDecodeErrorr   r%   )r   r   s     r   
bytes_reprr)   8   sS    %% 
t$$  T++s   
 

) 
66contentsc                 b   ^ SSR                  U4S jU R                  5        5       5      -   S-   $ )Nz{
 c              3   `   >#    U  H#  u  pS [        U5       S[        UT5       S3v   M%     g7f)z  z: z,
N)r   r)   ).0kvr   s      r   	<genexpr>dict_repr.<locals>.<genexpr>P   s5      2 0 a	Jq'$:#;3? 0s   +.})joinitems)r*   r   s    `r   	dict_reprr6   N   s:    GG 2 ( 02 22  r   
entrypointargsc                    [        S5      nUR                  5        Vs/ s H  oD(       d  M  UPM     nnUR                  S5        S1n[        X5      nUR	                  U5        UR                  SU S35        U(       a@  UR                  S5      u  pUR                  SU SU	 S	35        UR                  S
U S35        SR                  S U 5       5      $ s  snf )a  Creates a beipack with the given `contents`.

If `entrypoint` is given, it should be an entry point which is run as the
"main" function.  It is given in the `package.module:func format` such that
the following code is emitted:

    from package.module import func as main
    main()

Additionally, if `args` is given, it is written verbatim between the parens
of the call to main (ie: it should already be in Python syntax).
zbeipack_loader.pyr,   z
import sysz&sys.meta_path.insert(0, BeipackLoader(z)):zfrom z import z as mainzmain()c              3   *   #    U  H	  o S 3v   M     g7f)
N )r.   lines     r   r1   pack.<locals>.<genexpr>s   s     154V2;5s   )r
   
splitlinesappendr6   extendsplitr4   )
r*   r7   r8   loaderr?   linesr   contents_txtpackagemains
             r   packrJ   U   s      /0F$//1:1dTT1E:	LLnGX/L	LL	LL9,rJK"((-uWIXdV8<=uTF!_%7715111 ;s
   
CC	filenamesrelative_toc           	          0 nU  HF  n[        US5       nUR                  5       U[        R                  R	                  X1S9'   S S S 5        MH     U$ ! , (       d  f       M[  = f)Nrb)start)openreadospathrelpath)rK   rL   r*   filenamefiles        r   collect_contentsrW   v   sT    !#H(D!TEIYY[HRWW__X_AB "!  O "!s   /A
A 	name	recursivec          	         ^^ SS K nSSKJn  S[        SUS[        [
        [        [        4      4UU4S jjm[        T" U R                  SS5      UR                  R                  U 5      5      5      $ )	Nr   )TraversablerS   entryr   c              3     >#    UR                  5        Hi  nU  SUR                   3nUR                  5       (       a  X2R                  5       4v   M>  T(       d  MG  UR                  S:w  d  MY  T" X25       S h  vN   Mk     g  N	7f)N/__pycache__)iterdirrX   is_file
read_bytes)rS   r\   itemitemnamerY   walks       r   re   collect_module.<locals>.walk   sh     MMODq,H||~~ 111tyyM9/// $
 0s   ABB-B8B9
B.r^   )importlib.resourcesimportlib.resources.abcr[   strr   r   bytesdictreplace	resourcesfiles)rX   rY   	importlibr[   re   s    `  @r   collect_modulerq      sf    303 0{ 0xc5j8I/J 0 0 T\\#s+Y-@-@-F-Ft-LMNNr   rU   c                     0 n[         R                  " U 5       nUR                   H2  nSUR                  ;   a  M  UR	                  U5      XR                  '   M4     S S S 5        U$ ! , (       d  f       U$ = f)Nz.dist-info/)zipfileZipFilefilelistrU   rQ   )rU   r*   rV   r\   s       r   collect_ziprv      sc    H		"d]]E.'+yy'7H^^$ # 
# O 
#	" Os   AA&&
A5rS   c                     [         R                  " 5        nSS KnUR                  U 5      nUR                  SU5      n[	        U5      sS S S 5        $ ! , (       d  f       g = f)Nr   wheel)tempfileTemporaryDirectorybuildProjectBuilderrv   )rS   tmpdirr{   builderrx   s        r   collect_pep517r      sG    		$	$	&&&&t,gv.5!	 
'	&	&s   2A
A c                     [         R                  " 5       n U R                  SSSS9  U R                  SSSSS	9  U R                  S
SS9  U R                  SSSS9  U R                  SSSSS9  U R                  SSSSS9  U R                  SS/ SS9  U R                  SSS/ SS9  U R                  S S!S/ S"S#9  U R                  S$S%S&S'9  U R                  5       n[	        UR
                  UR                  S(9nUR                   H  nUR                  [        U5      5        M     UR                   H  nUR                  [        US)S*95        M     UR                   H  nUR                  [        U5      5        M     [        X!R                  UR                   5      R#                  S+5      nUR$                  (       a$  S,UR$                  R#                  S-5      -   S.-   U-   nUR&                  (       a#  [(        R*                  " U[(        R,                  S/9nUR.                  (       a1  [1        UR.                  S05       nUR3                  U5        S S S 5        g UR&                  (       a1  [4        R6                  " S15      (       a  [8        R:                  " S25        [8        R<                  R>                  R3                  U5        g ! , (       d  f       g = f)3Nz--pythonz-pz5add a #!python3 interpreter line using the given path)helpz--xzz-J
store_truezcompress the output with `xz`)actionr   z--topdirz6toplevel directory (paths are stored relative to this)z--outputz-oz(write output to a file (default: stdout)z--mainz-mzMODULE:FUNCz)use FUNC from MODULE as the main function)metavarr   z--main-argsARGSz$arguments to main() in Python syntaxr,   )r   r   defaultz--modulerB   z'collect installed modules (recursively))r   r   r   z--zipz-zz'include files from a zipfile (or wheel)z--buildDIRz%PEP-517 from a given source directory)r   r   r   r   ro   *zfiles to include in the beipack)nargsr   )rL   T)rY   r   s   #!r      
)presetwbr	   z1refusing to write compressed output to a terminal) argparseArgumentParseradd_argument
parse_argsrW   ro   topdirzipupdaterv   modulerq   r{   r   rJ   rI   	main_argsencodepythonxzlzmacompressPRESET_EXTREMEoutputrP   writerR   isattysysexitstdoutbuffer)parserr8   r*   rV   rX   rS   results          r   rI   rI      s   $$&F

DT  V
\<  >

U  W

DG  I
$H  J
vCR  Q

8RF  H
hF  H
	52D  F
s>  @D

DHD)*  tt<=  

t,-  (IIt~~6==gFF{{++G44u<vEwwvd.A.AB{{$++t$JJv %$ 77ryy||HHHI

' %$s   :K
K__main__)Nr,   r'   )r   N) r   r!   r   rR   r   ry   rs   typingr   r   r   r   r   r   r   r
   rj   r   rk   r   r   r%   r)   r6   rJ   rW   boolrq   rv   r   rI   __name__r>   r   r   <module>r      s  $    	 
   = =    55 5S 5D% DC D&E &CH & &,U ,SX ,# ,,S%Z( 3s8   &*24U
# 2c]222D 37S	 "*3-;?U
;KO OD OT#u*5E O	# 	$sEz"2 	" "c5j!1 "1(h zF r   