+
     hG  c                   s    ^ RI t ^ RIt^ RIHt ^ RIHtHtHtHtHtH	t	H
t
HtHtHtHt RtRtRR ltR tR tR	 tR
 tR tR tR tR tR tRR ltR tR t]R8X  d
   ]! 4        R# R# )    N)time)compress_streamdecompress_stream
CParameter
DParameter
train_dictZstdDictZstdFilecompressionLevel_valueszstd_version__version__PYZSTD_CONFIGi   i  c                 s    V ^,           V,          p\        W#,          4      pRV,          RW$,
          ,          ,           p\        RV^dV,          3,          RRR7       R# )i   Z+Z-z|%s| %.2f%%TZendflushN)intprint)ZprogressZtotalZwidthZpercentZnowZbars   &&&   6/usr/lib64/python3.14/site-packages/pyzstd/__main__.pyprogress_barr      sM     !|u$G
eo
C
)cU[)
)C	-3G,
,$dC    c                 s   V P                   '       ge   \        P                  P                  V4      '       d@   \	        R P                  V4      4      p\        4        VR8w  d   ^ RIpVP                  4        \        VR4      V n
        R# )z0output file already exists:
{}
overwrite? (y/n) ZyNZwb)fospathZisfileinputformatr   sysZexitopenoutput)argsr   Zanswerr   s   &&  r   open_outputr      s[    666bggnnT** 017?S=HHJtT"DKr   c                 s    V P                   e   V P                   P                  4        V P                  e   V P                  P                  4        R # R # N)r   closer   r   s   &r   close_filesr"   #   s;    zz

{{ r   c                 s@   V P                   ^ 8X  d   RpMRV P                   ,          pV P                  ^ 8  d   ^pV P                  pRV,          pM^ p^ pRp\        P                  V P                  \        P
                  V P                   \        P                  V\        P                  V\        P                  V P                  \        P                  V P                  /pRP                  V P                  WV P                  V P                  4      p\        V4       V# )r    zsingle-thread modezmulti-thread mode, %d threads.zyes, windowLog is %d.Znozc - compression level: {}
 - threads: {}
 - long mode: {}
 - zstd dictionary: {}
 - add checksum: {})ZthreadsZlongr   ZcompressionLevelZlevel	nbWorkersZenableLongDistanceMatching	windowLogZchecksumFlagchecksumZ
dictIDFlagwrite_dictIDr   zdr   )r   Zthreads_msgZuse_longr$   Zlong_msgoptionmsgs   &      r   compress_optionr*   *   s    ||q*6E yyA~II	*Y6	 ))4::""DLL33X""I%%t}}##T%6%68F! #)&

K#(	  
#JMr   c           	      s  a \         P                  P                  V P                  P                  4      oV P
                  f'   \        W P                  P                  R,           4       RP                  V P                  P                  V P
                  P                  4      p\        V4       \        V 4      pV3R lp\        4       p\        V P                  V P
                  VV P                  SVR7      p\        4       p\        V 4       V^ ,          ^ 8w  d    ^dV^,          ,          V^ ,          ,          pMRpRP                  ! Wd,
          .VOVN5!  p\        V4       R # )Nz.zstz4Compress file:
 - input file : {}
 - output file: {}c                     < \        V S4       R # r   r   Ztotal_inputZtotal_outputZ	read_dataZ
write_datainput_file_size   &&&&r   cbZcompress.<locals>.cbc       [/2r   )level_or_option	zstd_dictZpledged_input_sizecallback      Y@z\
Compression succeeded, {:.2f} seconds.
Input {:,} bytes, output {:,} bytes, ratio {:.2f}%.
)r   r   getsizer   namer   r   r   r   r*   r   r   r'   r"   )	r   r)   r(   r0   t1rett2ratior.   s	   &       @r   compressr<   O   s    ggoodjjoo6O {{D**//F23 !'

  "" 
 
#J T"F3	B
$**dkk*0$(GG-<#%	'C
 
B 1v{c!fs1v%CDJFKE   C 
#Jr   c                 s  a \         P                  P                  V P                  P                  4      oV P
                  fe   V P                  fW   ^ RIHp V! RRV P                  P                  4      w  r#V'       g   V P                  P                  R,           p\        W4       \        P                  V P                  /pV P
                  e   V P
                  P                  pMRp\        RP                  V P                  P                  WPP                  4      4       V3R lp\        4       p\!        V P                  V P
                  V P                  VVR7      p\        4       p	\#        V 4       V^,          ^ 8w  d    ^dV^ ,          ,          V^,          ,          p
MR	p
R
P                  ! W,
          .VOV
N5!  p\        V4       R # )N)subnz(?i)^(.*)\.zst$z\1z.decompressedZNonezMDecompress file:
 - input file : {}
 - output file: {}
 - zstd dictionary: {}c                 r+   r   r,   r-   r/   r   r0   Zdecompress.<locals>.cb   r1   r   )r3   r(   r4   r5   z^
Decompression succeeded, {:.2f} seconds.
Input {:,} bytes, output {:,} bytes, ratio {:.2f}%.
)r   r   r6   r   r7   r   testZrer=   r   r   windowLogMaxr   r   r'   r   r   r"   )r   r=   out_pathZreplacedr(   Zoutput_namer0   r8   r9   r:   r;   r)   r.   s   &           @r   
decompressrA   x   sk   ggoodjjoo6O {{tyy0!"4eTZZ__Mzz8HD# %%t'8'89F {{kk&&	 $ &,VJJOO[''&343	B
DJJ&*ggf%')C 
B 1v{c!fs1v%CDJFKE   C 
#Jr   c           	      s   ^ RI H p V P                  f   Rp\        V4      h\        RRR7       . pV! V P                  RR7       F_  p\        VR4      ;_uu_ 4       pVP                  4       pVP                  V4       \        R	\        V4      ,          R
RR7       RRR4       Ka  	  \        V4      ^ 8X  d   \        R4      h\        R V 4       4      pV^ 8X  d   \        R4      hRP                  V P                  \        V4      TV P                  P                  V P                  V P                  f   RMV P                  4      p\        VRR7       \        4       p\        W0P                  4      p	\        4       p
V P                  er   \        V	P                   4      ^8  dX   V	P                   R,          V P                  P#                  ^R4      ,           V	P                   R,          ,           p\%        V4      p	V P                  P'                  V	P                   4       \)        V 4       RP                  W,
          V	4      p\        V4       R#   + '       g   i     EK  ; i)r    )globNz4need to specify output file using -o/--output optionzGathering samples, please wait.Tr   )Z	recursiverbzsamples count: %dr   r   z,No samples gathered, please check GLOB_PATH.c              3   s8   "   T F  p\        V4      x  K  	  R # 5ir   )len).0Zsample   & r   	<genexpr>Ztrain.<locals>.<genexpr>   s     5vs6{{s   z&Samples content is empty, can't train.zGathered, train zstd dictionary:
 - samples: {}
 - samples number: {}
 - samples content: {:,} bytes
 - dict file: {}
 - dict max size: {:,} bytes
 - dict id: {}
Training, please wait.ZrandomNi   NZlittle:i   NNz3Training succeeded, {:.2f} seconds.
Dictionary: {}
)rB   r   	Exceptionr   trainr   readZappendrE   sumr   r7   ZmaxdictZdictIDr   r   Zdict_contentZto_bytesr   Zwriter"   )r   rB   r)   ZlstZfiler   ZdatZsamples_sizer8   r'   r:   Zcontents   &           r   rK   rK      s    {{Dn 

+48
CTZZ40$&&(CJJsO%C0d$G  1
 3x1}FGG555Lq@AA$ &,V

CHl  $,, KK/T[[&B  
#T 
B	C	&B	B {{3r#71#<//"%KK((H56OOB'( g 	KKboo&%vbeR0 	#J[ s   A II$c                  s(    ^ RI Hp   ! R RV 4      pV# )r    )TarFilec                   sN   a a ] tR t^t oRRRRR/V 3R llltV 3R ltRtVtV ;t# )$get_ZstdTarFile.<locals>.ZstdTarFiler2   Nr3   c               s   < \        WVVR 7      V n         \        SV `  ! RRV P                  RV/VB  R#    T P                  P	                  4        h ; i))r2   r3   fileobjmodeN )r   	zstd_filesuper__init__r    )selfr7   rQ   r2   r3   Zkwargs	__class__s   &&&$$,r   rU   Z-get_ZstdTarFile.<locals>.ZstdTarFile.__init__   sT    %d6E09;DN MMdMfM$$&s	   6 Ac                s   <  \         SV `  4        V P                  P                  4        R #   T P                  P                  4        i ; ir   )rT   r    rS   )rV   rW   s   &r   r    Z*get_ZstdTarFile.<locals>.ZstdTarFile.close   s2    '$$&$$&s	   - A	)rS   )r)	__name__
__module____qualname____firstlineno__rU   r    __static_attributes____classdictcell__Z__classcell__)rW   __classdict__s   @@r   ZstdTarFilerO      s'     	d 	d 	 		' 	'r   r`   )ZtarfilerN   )rN   r`   s     r   get_ZstdTarFilera      s    'g '" r   c                 sl   V P                   P                  \        P                  4      V n         \        P                  P                  V P                   4      '       g   R V P                   ,           p\        V4      h\        P                  P                  V P                   4      w  r#V P                  f2   \        P                  P                  W#R,           4      p\        W4       \        4       pRP                  V P                   V P                  P                  4      p\        V4       \        V 4      p\        RRR7       \!        4       pV! V P                  RVV P"                  R7      ;_uu_ 4       pVP%                  V P                   V4       VP&                  P)                  4       p	RRR4       \!        4       p
V P                  P)                  4       p\+        V 4       X	^ 8w  d   ^dV,          V	,          pMR	pR
P                  W,
          WV4      p\        V4       R#   + '       g   i     L; i)zTar archive input dir invalid: Nz.tar.zstz;Archive tar file:
 - input directory: {}
 - output file: {}zArchiving, please wait.TrC   Zw)rQ   r2   r3   r5   zZArchiving succeeded, {:.2f} seconds.
Input ~{:,} bytes, output {:,} bytes, ratio {:.2f}%.
)tar_input_dirZrstripr   Zsepr   isdirNotADirectoryErrorZsplitr   Zjoinr   ra   r   r7   r   r*   r   r'   ZaddrP   tellr"   )r   r)   ZdirnameZbasenamer@   r`   r(   r8   r   uncompressed_sizer:   Zoutput_file_sizer;   s   &            r   tarfile_createrg      s   ++22266:D77==++,,/$2D2DD %%d&8&89G {{77<<J)>?D# "#K !'""  "" 
 
#J T"F 

#40	B	T[[s%+#ww
( 
(+,	d  (+IINN,	
(
 
B{{'') A&&)::DEKVE$F?  
#J'
( 
(s   57H##H3	c                 s   V P                   f   Rp\        V4      h\        P                  P	                  V P                   P
                  4      p\        P                  P                  V P                  4      '       g   RV P                  ,           p\        V4      h\        4       p\        P                  V P                  /pRP                  V P                   P
                  V P                  V P                  4      p\        VRR7       \        4       pV! V P                   RV P                  VR7      ;_uu_ 4       pVP!                  V P                  4       VP"                  P%                  4       pR R R 4       \        4       p\'        V 4       X^ 8w  d   ^dV,          V,          p	MRp	R	P                  W,
          W'V	4      p\        V4       R #   + '       g   i     Le; i)
Nz8need to specify input file using -d/--decompress option.z Tar archive output dir invalid: zhExtract tar archive:
 - input file: {}
 - output dir: {}
 - zstd dictionary: {}
Extracting, please wait.TrC   rX   )rQ   r3   r2   r5   z[Extraction succeeded, {:.2f} seconds.
Input {:,} bytes, output ~{:,} bytes, ratio {:.2f}%.
)r   ZFileNotFoundErrorr   r   r6   r7   rc   tar_output_dirrd   ra   r   r?   r   r'   r   r   Z
extractallrP   re   r"   )
r   r)   r.   r`   r(   r8   r   rf   r:   r;   s
   &         r   tarfile_extractri   ,  s   zzH$$ggoodjjoo6O 77==,,--043F3FF %% "#K %%t'8'89F& (.v

##(	  
#T 
B	TZZc#ww%+
- 
-01	T(()IINN,	
-
 
B Ao%(99DEKVE?uF>  
#J!
- 
-s   <6GG	c                 sH   a aa  ! VVV 3R  lR\         P                  4      pV# )c                   s6   <a  ] tR tRt o RVVV3R lltRtV tR# )!range_action.<locals>.RangeActioni^  Nc                s8  <  \        V4      pS
Tu;8:  d   S	8:  gI   M S'       d   RP                  \        ^ ,          4      pMRpRP                  YdS
S	T4      p\	        T4      h\        Y P                  T4       R#    \        R P                  T4      4      h; i)z{} should be an integerzin {}-bit build, Z z7{}{} value should: {} <= v <= {}. provided value is {}.N)r   Z	TypeErrorr   r   Z
ValueErrorZsetattrdest)rV   Zparserr   ZvaluesZoption_stringZvZbitsr)   bits_msgmaxmins   &&&&&   r   __call__Z*range_action.<locals>.RangeAction.__call___  s    QK
 1OO.55mA6FGDD/06S#q1:  !o%D))Q'#Q 9 @ @ OPPs   A= =BrR   r   )rY   rZ   r[   r\   ro   r]   r^   )r_   rl   rm   rn   s   @r   RangeActionrj   ^  s     	( 	(r   rp   )argparseZAction)rn   rm   rl   rp   s   fff r   range_actionrr   ]  s     ( (hoo (. r   c                  sf	   \         P                  ! R RR\         P                  R7      p V P                  R4      pVP	                  RRR\         P
                  ! R4      R	R
7       VP	                  RRR\        RR
7       VP	                  RRRR7       V P                  R4      pVP                  4       pVP	                  RRR\        RR
7       VP	                  RR\        RR
7       VP	                  RRR\        P                  \        \        P                  \        P                  4      RP                  \        P                  \        P                  \        P                  4      R7       VP	                  RRR^ \        . \        P                  P!                  4       OR N5!  R!R7       VP	                  R"RR#^RK\        . \        P"                  P!                  4       OR N5!  R$R%7       VP	                  R&R'R(R R)R*7       VP	                  R+R'R,R R-R*7       V P                  R.4      pVP                  4       pVP	                  R/R0R\        R1R
7       VP	                  R2R\        R3R
7       VP	                  R4R\        R5R
7       VP	                  R6R^ \        . \$        P&                  P!                  4       OR N5!  R7R7       V P                  R84      pVP	                  R9R:\        R;R
7       VP	                  R<R=\(        R>R?R@7       VP	                  RARBRC\        ^RD4      RER7       V P+                  4       pVP,                  e#   \/        VP,                  R\0        RF7      Vn        MgVP4                  e#   \/        VP4                  R\6        RF7      Vn        M7VP8                  e#   \/        VP8                  R\6        RF7      Vn        MRCVn        VP:                  e   \=        W3P:                  4       VP>                  eR   VP>                  PA                  4       pVP>                  PC                  4        VRG,          RH8g  p\E        WE4      Vn#        MRCVn#        VP,                  VP4                  VP8                  VPH                  VPJ                  .p\M        RI V 4       4      ^8  d   \O        RJ4      hV# )LzCLI of pyzstd modulezThe command style is similar to zstd's CLI, but there are some differences.
Zstd's CLI should be faster, it has some I/O optimizations.a  Examples of use:
  compress a file:
    python -m pyzstd -c IN_FILE -o OUT_FILE
  decompress a file:
    python -m pyzstd -d IN_FILE -o OUT_FILE
  create a tar archive:
    python -m pyzstd --tar-input-dir DIR -o OUT_FILE
  extract a tar archive, output will forcibly overwrite existing files:
    python -m pyzstd -d IN_FILE --tar-output-dir DIR
  train a zstd dictionary, ** traverses sub-directories:
    python -m pyzstd --train "E:\cpython\**\*.c" -o OUT_FILE)ZprogZdescriptionZepilogZformatter_classzCommon argumentsz-Dz--dictZFILErD   z<use FILE as zstd dictionary for compression or decompression)metavartypehelpz-oz--outputzresult stored into FILEz-fZ
store_truez7disable output check, allows overwriting existing file.)actionru   zCompression argumentsz-cz
--compresszcompress FILEz--tar-input-dirZDIRzJcreate a tar archive from DIR. this option overrides -c/--compress option.z-lz--levelZ#z/compression level, range: [{},{}], default: {}.)rs   defaultrv   ru   z-tz	--threadsTz^spawns # threads to compress. if this option is not specified or is 0, use single thread mode.z--longZ?zBenable long distance matching with given windowLog (default #: 27))rs   ZnargsZconstrw   rv   ru   z--no-checksumZstore_falser%   z,don't add 4-byte XXH64 checksum to the frame)rv   rk   rw   ru   z--no-dictIDr&   zBdon't write dictID into frame header (dictionary compression only)zDecompression argumentsz-dz--decompresszdecompress FILEz--tar-output-dirztextract tar archive to DIR, output will forcibly overwrite existing files. this option overrides -o/--output option.z--testz)try to decompress FILE to check integrityz--windowLogMaxz9set a memory usage limit for decompression (windowLogMax)zDictionary builderz--trainZ	GLOB_PATHz0create a dictionary from a training set of filesz	--maxdictZSIZEi  z0limit dictionary to SIZE bytes (default: 112640))rs   rt   rw   ru   z--dictIDZDICT_IDNl    z-specify dictionary ID value (default: random))Z	bufferingrI   s   70c              3   s0   "   T F  qf   K  ^x  K  	  R # 5ir   rR   )rF   ZirG   r   rH   Zparse_arg.<locals>.<genexpr>  s     
1i11is   
zWrong arguments combinationi)(rq   ZArgumentParserZRawDescriptionHelpFormatterZadd_argument_groupZadd_argumentZFileTypeZstrZadd_mutually_exclusive_groupr	   rw   rr   rn   rm   r   r   r#   Zboundsr$   r   r?   r   Z
parse_argsr<   r   C_READ_BUFFERr   rA   D_READ_BUFFERr>   r   r   ZdictrL   r    r   r'   rK   rb   rM   rJ   )ZpZgZgmr   Z
zd_contentZis_rawZ	functionss          r   	parse_argrz   w  sp   1$=
^ %-$H$H#	JA& 	
/0ANN468I8I$8OV  XNN4V#1  3NN4Q  S 	
45A	
	'	'	)BOOD,S(  *OO%u3H  J NN4C2::&'>'B'B'>'B'BDI6155155199;  < NN4c1&L
(<(<(C(C(ELtLF  H NN8S2r&L
(<(<(C(C(ELtL\  ^ NN?="DF  H NN=&\  ^ 	
67A	
	'	'	)BOOD.&s*  ,NN%u3E  G OOHf3D  FNN#S!&O
(?(?(F(F(HO$OS  U 	
12ANN9kJ  LNN;S&J  LNN:y$&q*5G  I <<>D }} $--$13
		$$//4$13
		$))T$13
 
 {{D++& yyYY^^%
		B#66:. DJJ(:(:<I

1i
11A5566Kr   c                  s   \        R P                  \        \        4      4       \	        4       p V P
                  '       d   \        V 4       R# V P                  '       d   \        V 4       R# V P                  '       d   \        V 4       R# V P                  '       g   V P                  '       d   \        V 4       R# V P                  '       d   \        V 4       R# \        R4       R# )z-*** pyzstd module v{}, zstd library v{}. ***
z2Invalid command. See help: python -m pyzstd --helpN)r   r   pyzstd_versionr
   rz   rb   rg   rh   ri   r<   rA   r>   rK   r!   s    r   mainr|     s    	
:
&
.0 ;Dt						DIII4	dBCr   Z__main__)i2   )F) rq   r   r   Zpyzstdr   r   r   r   r   r   r   r	   r
   r   r{   r   rx   ry   r   r   r"   r*   r<   rA   rK   ra   rg   ri   rr   rz   r|   rY   rR   r   r   <module>r}      s     	 @ @ @ @ D##J'R-^9v.1f/b4sjD& zF r   