+
    id  c                   sd   ^ RI t ^ RIt^ RIt^ RIt^ RIHtHtHt ^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt  ^ RIHt ]P6                  ! R4      tRt ^ RIt]P>                  ! ] 4       R	tRt&. R6Ot'R t(R7R lt)R t*R8R lt+R t,R t-R t.R9R lt/R t0R:R lt1R R lt2]&RRRRRRRRRRR3R lt3R;R lt4R:R  lt5R<R! lt6R=R" lt7] Pp                  3R# lt9R$ t:R% t;R& t<R' t=R( t>R)] P~                  /R* lt@R+ tA. 3R, ltB ! R- R.4      tC ! R/ R0]P                  4      tE ! R1 R2]P                  4      tF ! R3 R4      tG ! R4 R4      tH ! R5 R]I4      tJR#   ] d    ^ RIHt  EL"i ; i  ]]!3 d+    ^ R
I"H#t# Rt$]PK                  R]#! ]$^HRR7       R24        EL+i ; i)>    N)PopenPIPESTDOUT)closing)deque)parse)parse_versionZsosFT)fillzWARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module.
Z
)Zreplace_whitespacei,  ImporterHelperSoSTimeoutErrorTempFileUtilc                s:   \         P                  ! R4      p VP                  V ^R7      w  r#pV'       g   V # \         P                  ! RRV4      P	                  R4      pV RV 2pV#   \
         d(   p\        P                  RT  RT 24       T u R	p?# R	p?ii ; i)
z;Convert the version into a PEP440 compliant version scheme.z2^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?)Zmaxsplitz[+~]+.Z-Z+zUnable to format z to pep440 format: N)reZcompilesplitZsubZstrip	Exceptionlogdebug)verZpublic_version_re_ZpublicZlocalZsanitized_localZpep440_versionZerrs   &       2/usr/lib/python3.14/site-packages/sos/utilities.pyformat_version_to_pep440r   P   s    

A	,2232C5J&&#u5;;C@"81_$56 		%cU*=cUCD
s"   A( /A( (B3BBBc                sT    V'       d   \        V 4      p\        V4      # \        V 4      # )z5Converts the version to PEP440 format before parsing )r   r   )r   Zpep440Z
ver_pep440   && r   sos_parse_versionr   a   s%    -c2
Z((    c                s    \        V R4      ;_uu_ 4       p\        P                  ! V 4      P                  V8  d   VP	                  V) ^4       VP                  4       uuRRR4       #   + '       g   i     R# ; i)z,Returns the last number_of_bytes of filenameZrbN)openosZstatst_sizeZseekread)ZfilenameZnumber_of_bytesfr   r   tailr   j   sQ    	h		778$$6FFO#Q'vvx 
			s   AA((A9	c                s    \        V \        4      '       d    \        WRR7      # \        V 4      #   \         d;    \        P                  RT  R24       \        \        P                  ! 4       4      u # i ; i)z@Returns a file-like object that can be used as a context managerutf-8encodingz	fileobj: z could not be opened)	
isinstancestrr   IOErrorr   r   r   ioZStringIO)Zpath_or_fileZmode   &&r   fileobjr'   r   sf    ,$$	*W==
 |$$	  	*II	,/CDE2;;=))	*s   0 AA54A5c                s    RRRRRRRR	/pVP                  4        F$  w  r#W8  g   K  \        V 4      V,          R V 2u # 	  V  # )
zCConverts a number of bytes to a shorter, more human friendly formatZTZGZMZKz.1fl        i   @      )itemsZfloat)Z	num_bytesZsizesZsymbolsize   &   r   convert_bytesr-   ~   sV    '3gsGDEI&-c26(;; & [r   c                sF   V R	R R
9   d   \        V RRR7      ;_uu_ 4       pVP                  4       p\        P                  ! RV4      '       d    RRR4       R# \        P                  ! RV4      '       d    RRR4       R#  RRR4       R# R#   + '       g   i     R# ; i)an  Helper to determine if a given file is a certificate or not.

This is especially helpful for `sos clean`, which cannot obfuscate
certificate files content and instead, by default, will keep them as is.

:param fname:   The full path of the file to check
:type fname:    ``str``

:returns:   The type of the certificate or ``None``
:rtype:     ``string`` or ``None``
Nrr   r    z-----BEGIN CERTIFICATE-----Zcertificatez"-----BEGIN [A-Z]+ PRIVATE KEY-----Zcertificatekeyi)z.csrz.crtz.pem)r   r   r   Zsearch)fnamer   Zcontent   &  r   file_is_certificater1      s     RSz--%w//1ffhGyy7AA$ 0/ yy>HH' 0/ I	 0  0/ s   /BB7BB 	c                s  a \         '       dr    \        P                  ! V 4      oRR.pSP                  R8H  ;'       d@    \        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       * # \        V RRR	7      ;_uu_ 4       p VP                  ^4        R
R
R
4       R#   \
         d     LAi ; i  \         d     R
R
R
4       R# i ; i  + '       g   i     R
# ; i)a^  Helper to determine if a given file contains binary content or not.

This is especially helpful for `sos clean`, which cannot obfuscate binary
data and instead, by default, will remove binary files.

:param fname:   The full path of the file to check binaryness of
:type fname:    ``str``

:returns:   True if binary, else False
:rtype:     ``bool``
ztext/zinode/binaryc              3   sZ   <"   T F   pSP                   P                  V4      x  K"  	  R # 5iN)Z	mime_type
startswith).0Z_mt_ftup   & r   	<genexpr>Z!file_is_binary.<locals>.<genexpr>   s#     FvEOO..s33vs   (+TFZtrr   r    N)		magic_modmagicdetect_from_filenamer!   anyr   r   r   ZUnicodeDecodeError)r/   Z_mimesZtfiler6   s   &  @r   file_is_binaryr=      s     y	..u5Ex(F(* G GFvFFvFF0G 
eTG	,	,	 JJqM 
-	,	  		 " 	 
-	,	 
-	,	,sL   /B3 B3 B3 "B3 CC3C CCCCCC/	c              #  s4  "   V'       dO   \         P                  P                  V4      P                  \         P                  P                  4      pW$,          p\         P
                  ! V4       F  w  rVpV'       d2   VP                  \         P                  P                  4      V8  d   VR V'       d   \        P                  ! WS4      '       g   Ke  \        P                  ! Wp4       F$  p\         P                  P                  WX4      x  K&  	  K  	  R# 5i)zGenerator function to find files recursively.
Usage::

    for filename in find("*.properties", "/var/log/foobar"):
        print filename
:NNNN)	r   pathdirnameZcountsepZwalkfnmatchZfilterjoin)	Zfile_patternZtop_dirZ	max_depthZpath_patternZ
base_depthr>   ZdirlistZfilelistnames	   &&&&     r   findrD      s      WW__W-33BGGKK@
	#%777#3xBGGKK0I=
 C CNN8:D'',,t** ; $4s   B3D6A"Dc                s   a  . pV F:  p\        V4      ;_uu_ 4       pVP                  V 3R lV 4       4       RRR4       K<  	  V#   + '       g   i     KQ  ; i)zReturns lines matched in fnames, where fnames can either be pathnames to
files to grep through or open file objects to grep through line by linec              3   sf   <"   T F&  p\         P                  ! SV4      '       g   K"  Vx  K(  	  R # 5ir3   )r   Zmatch)r5   linepatternr7   r   r8   Zgrep.<locals>.<genexpr>   s      KRT288GT3JDDRs   1
1N)r'   extend)rF   Zfiles_or_pathsZmatchesZfopZfos   f*   r   greprH      sI     GS\\RNNKRKL \  N \\s   AAc           
     s   \         P                  P                  RR4      P                  \         P                  P
                  4      pV .V Uu. uF"  p\         P                  P                  W04      NK$  	  up,           pV'       dF   TV Uu. uF1  p\         P                  P                  WP                  R4      4      NK3  	  up,          p\        ;QJ d    R V 4       F  '       g   K   R# 	  R# ! R V 4       4      # u upi u upi )z6Returns if a command matches an executable on the PATHZPATH /c              3   sl   "   T F*  p\         P                  ! V\         P                  4      x  K,  	  R # 5ir3   )r   accessZX_OK)r5   r>      & r   r8   Z is_executable.<locals>.<genexpr>   s"     ?JDryyrww''Js   24TF)	r   environZgetr   r>   ZpathseprB   lstripr<   )commandsysrootZpathspZ
candidatesZcs   &&    r   is_executablerR      s     JJNN62&,,RWW__=EF1bggll16FFJ:D
:DQBGGLL((3-0*
 	

 3?J?33?3?3?J??? G
s   (D 7Dc                s$    V ^8  d   QhR\         /# )   url)r#   )Zformats   "r   __annotate__rU      s      c r   c                s   ^ RI HpHp  V! V 4      pVP                  '       g   VP                  '       d   RpVP
                  '       d   WCP
                  ,          pVP                  '       d   VRVP                   2,          pV! VP                  WCP                  VP                  VP                  VP                  34      # V #   \         d    T u # i ; i)zC
Replace username:password@ with ********@ in proxy URL if present
)urlparse
urlunparsez	********@Z:)Zurllib.parserV   rW   ZusernameZpasswordZhostnameZportZschemer>   ZparamsZqueryZfragmentr   )rT   rV   rW   Z
parsed_urlZnetlocs   &    r   scrub_url_credentialrX      s     2c]
*"5"5"5 F"""---Ajoo.//!!6??!!:#3#3Z5H5H   
 
s.   C C C 
#C .AC C CCc                s  aaa	a VVV3R lpV	3R lpS'       dE    \         P                  ! S4      pTP                  RTP                  RSR	TP                  R
S/4       \
        P                  P                  4       pRVR&   V'       d<   VP                  4        F'  w  ppV'       d   VVV&   K  VP                  VR4       K)  	  V'       d'   \        R4      '       d   RV'       d   RMR RV RV  2p \        P                  ! V 4      p. pV Fv  pVP                  R4      '       dL   RV9   dE   \        P                  ! V4      pV'       d   VP                  V4       KR  VP!                  V4       Ke  VP!                  V4       Kx  	  V
'       dZ   V'       d   \"        pMPV'       d6   \$        P&                  ! \
        P(                  P+                  V
4      R7      pM\-        V
R4      pM\"        p \/        TRTV'       d   \0        M\"        RVRVR7      ;_uu_ 4       pV
'       dw   V'       db   V'       d6   \$        P&                  ! \
        P(                  P+                  V
4      R7      pM\-        V
R4      p\3        VP4                  VW4      pM#\7        VV4      pM\9        VP4                  W4      pS	'       d   VP:                  '       d   V! V4       K  M TP=                  V'       d   TMR4       VPM                  4       f   K  V
'       dT   V'       dL   \-        V
R4      ;_uu_ 4       p\C        TTVPF                  ;'       g    VPN                  ^ 8g  4       RRR4       VPN                  R9   d   RpMVPE                  4       pRVPN                  RVRVPF                  /uuRRR4       \I        VR4      '       d   VPK                  4        # #   \         d    R^RRRR/u # i ; i  \>         d    TPA                  4        T
'       dG   T'       d?   \-        T
R4      ;_uu_ 4       p\C        TTR4       RRR4       M  + '       g   i     M; iRTn        R^|RTPE                  4       RTPF                  /u uuRRR4       \I        TR4      '       d   TPK                  4        # # i ; i  + '       g   i     ELZ; i  + '       g   i     Mg; i  \P         dW   pTPR                  \R        PT                  8X  d1   R^RRRR/u Rp?\I        TR4      '       d   TPK                  4        # # ThRp?ii ; i \I        TR4      '       d   TPK                  4        R# R#   \I        TR4      '       d   TPK                  4        i i ; i)zExecute a command and return a dictionary of status and output,
optionally changing root or current working directory before
executing command.
c                  s  < S'       d   SR 8w  d   \         P                  ! S4       S'       d   \         P                  ! \        P                  ! S4      P
                  4       \         P                  ! \        P                  ! S4      P                  4       \         P                  ! \        P                  ! S4      P                  4       S '       d   \         P                  ! S 4       R# R# )rJ   N)
r   chrootZsetgidpwdgetpwnamZpw_gidZsetuidZpw_uidchdirpw_dir)r\   rY   runass   r   _child_prep_fnZ.sos_get_command_output.<locals>._child_prep_fn  s    fmIIfIIcll5)001IIcll5)001HHS\\%(//0HHUO r   c                 s   < S! 4       '       g   V P                  4       ^|8X  d   V P                  4        \        h\        P                  ! R4       R# )i|   {Gz?N)poll	terminater
   timesleep)Zprocpollers   &r   _check_pollerZ-sos_get_command_output.<locals>._check_poller  s3    88tyy{c)NN!!

4r   ZstatusoutputrI   Z	truncatedZHOMEZLOGNAMEZPWDZUSERzC.UTF-8ZLC_ALLNtimeoutztimeout z--foregroundZ zs rJ   *ZdirZwbFT)ZshellstdoutstderrZbufsizeenvZ	close_fdsZ
preexec_fncloser   )i~   i   )+rZ   r[   ZKeyErrorZupdater]   r   rM   Zcopyr*   ZpoprR   shlexr   r4   globrG   appendr   tempfileZTemporaryFiler>   r?   r   r   r   
HeadReaderrk   
FakeReader
TailReaderrunningZwaitr   rb   tac_logsget_contentsis_fullZhasattrrn   ra   Z
returncodeOSErrorerrnoZENOENT)rO   rh   rl   rY   r\   rm   Z
foregroundr2   	sizelimitre   Zto_fileZtacr^   r_   rf   Zpwd_userZcmd_envkeyZvalueZargsZexpanded_argsZargZexpanded_argZ_outputrQ   Zreaderf_dstrk   es   &&&ff&&&&f&&f                r   sos_get_command_outputr     sx    	B||E*H 	

HOOu8??E	
 	 jjooG!GH
))+JC$C&	 & =++
nC1WI Ni! ;;wDM>>#3#:99S>L$$\2$$S)  %  G,,1IJG 7D)GB=g$*&7d,. . 23"*"8"8 " 8#
 #'w"5''9MF'62F#AHHi@nnn!!$ %9 FFg748 &&("3'4((EWe#^^@@q||q/@B ) ||z),,. !,,&V^^m. .@ 7G$$MMO %c  	Bc8RbAA	BZ ! 
9KKM!%gt!4!4 (% > "5!4!4!4 &+FN$c8V5H5H5J'9 9K. .@ 7G$$MMO %I
9" )(([. .v  77ell"c8RbAA 7G$$MMO % w.@ 7G$$MMO %77G$$MMO %s   O /-S R>-R>5BR>9R>R>O'*O'2R>R>R>*/R*	AR> 
S O$#O$'"R'
R'R'&P=4	R'=Q/R'7R>8
S &R''R>*R;5	R>>S		S U S T2&T-T2U +T--T22U %Vc                sn   Rp^
p^ pV P                  4        \        P                  ! V P                  4       4      P                  ^ 8X  d   R# \
        P
                  ! V P                  4       ^ \
        P                  R7      ;_uu_ 4       pVP                  4       ^,
          ;rxWh,          V8w  d   RpV^ 8  db   VP                  V^ V4      pWg^,           ,          V8X  d   VR8X  d   M2K8  V'       d   RpM!VP                  Wg^,           V^,            4       TpKh  RRR4       R#   + '       g   i     R# ; i)zPython implementation of the tac utility with support
for multiline logs (starting with space). It is intended
to reverse the output of 'journalctl --reverse'.
s   
N)rK   TFro   )
flushr   ZfstatZfilenor   mmapZACCESS_READr+   Zrfindwrite)	f_srcr   Zdrop_last_logZ	NEWLINE_BZ	NEWLINE_IZSPACE_IZmmZsep1Zsep2s	   &&&      r   rx   rx     s    
 IIG 
KKM	xx''1,	5<<>1T-=-=	>	>"ggik!8y  Mai88Iq$/D q&zW$ 2:  % BAvd1f-.D5 
?	>	>	>s   	A'D#1(D##D4	c                s   V P                  R4      R,          p \        V \        4       \        4       V.4      p\        P                  ! T\        P                  4       UUu. uF  w  rVTP                  T 8X  g   K  TNK  	  pppT'       d%   T Uu. uF  p\        Y4      '       g   K  TNK  	  ppT#   \         d-   p\        RT  RTP                  P                   24       ThRp?ii ; iu uppi u upi )a  Imports the module module_fqname and returns a list of defined classes
from that module. If superclasses is defined then the classes returned will
be subclasses of the specified superclass or superclasses. If superclasses
is plural it must be a tuple of classes.r   z"Error while trying to load module z:  Nro   )Z
rpartitionZ
__import__ZglobalsZlocalsImportErrorZprint	__class____name__inspectZ
getmembersZisclass
__module__Z
issubclass)	Zmodule_fqnameZsuperclassesZmodule_namemoduler   ZcnameZclass_ZmodulesZms	   &&       r   import_moduler     s    
  **3/3KM79fhN !!&'//:6: (%##}4 v:  6 %EgA)D11gEN  2=/ B++&&') 	*6 Fs/   B2 !C,;C,C2(C22C)='C$$C)c                s*    \        WW#R7      R,          # )z]Shell out to an external command and return the output or the empty
string in case of error.
)rh   rY   r\   rg   )r   )Zcmdrh   rY   Zrunats   &&&&r   	shell_outr     s      "#)/>>FH Hr   c                 st    . ROp^ pV R8  d   V^8  d   V^,          pV R,          p K"  V RV R2 W#,           2# )Br)   g      @r   r   )r   ZKiBZMiBZGiBZTiB )r+   Z	precisionZsuffixesZsuffixindex   &&  r   get_human_readabler     sJ    0HK
++/qF{1YKq.!("7!899r   c                 s    V'       d[   V\         P                  8w  dF   V P                  V4      '       g/   \         P                  P	                  WP                  R 4      4      p \        W24      pV! V 4      # )rJ   )r   r@   r4   r>   rB   rN   Zgetattr)r>   rP   Zmethodr   Z_meths   &&&& r   _os_wrapperr     sN    7bff$w''77<<S)9:DF#E;r   c                 sL    R V 9   d   \        WR\        R7      # \        WR4      # )ri   rq   )r   exists)r   rq   r>   rP   r&   r   path_existsr     s%    
d{4&>>th//r   c                     \        WR 4      # )isdirr   r   r&   r   
path_isdirr     s    tg..r   c                 r   )Zisfiler   r   r&   r   path_isfiler         th//r   c                 r   )Zislinkr   r   r&   r   path_islinkr     r   r   c                 s$    \        WR \        4      # )listdir)r   r   r   r&   r   r   r     s    ti44r   rP   c                s    V'       dT   V P                  V4      '       g=   \        P                  P                  WP	                  \        P
                  4      4      p \        P                  P                  ! V .VO5!  # r3   )r4   r   r>   rB   rN   r@   )r>   rP   rQ   s   &$*r   	path_joinr     sJ    tw//ww||G[[%8977<<!q!!r   c                s"    RV ,           R,           # )a
  Helper to make text bold in console output, without pulling in
dependencies to the project unneccessarily.

:param text:    The text to make bold
:type text:     ``str``

:returns:       The text wrapped in the ASCII codes to display as bold
:rtype:         ``str``
z[1mz[0mr   )Ztext   &r   boldr     s     ti''r   c                sN  a . p. pVP                  V4       \        V \        4      '       d   V P                  4        F  w  poVP	                  V4       V'       d   WA9   d   VP                  \        S4      4       KA  \        S\        4      '       g   KY   VP                  \        V3R lV 4       4      ^ ,          4       VP                  SP                  4       4       K  	  MVP                  V 4       V Uu. uF  qUV9  g   K  VNK  	  up#   \         d     L\i ; iu upi )a  Recursively compile all elements of a potentially nested dict by a set
of keys. If a given key is a dict within ``dobj``, then _all_ elements
within that dict, regardless of child keys, will be returned.

For example, if a Plugin searches the devices dict for the 'storage' key,
then all storage devices under the that dict (e.g. block, fibre, etc...)
will be returned. However, if the Plugin specifies 'block' via ``keys``,
then only the block devices within the devices['storage'] dict will be
returned.

Any elements passed here that are _not_ keys within the dict or any nested
dicts will also be returned.

:param dobj:    The 'top-level' dict to intially search by
:type dobj:     ``dict``

:param keys:    Which keys to compile elements from within ``dobj``. If no
                keys are given, all nested elements are returned
:param keys:    ``list`` of ``str``

:returns:       All elements within the dict and any nested dicts
:rtype:         ``list``
c              3   sF   <"   T F  qS9   g   K  SV,          x  K  	  R # 5ir3   r   )r5   r~   vr7   r   r8   Z/recursive_dict_values_by_key.<locals>.<genexpr>A  s       5.2sQhFAcFFds   !!)rG   r"   Zdictr*   rr   recursive_dict_values_by_keyZ
IndexErrorkeys)Zdobjr   Z_itemsZ_filtZkZdr   s   &&    @r   r   r     s    0 FE
MM$$JJLDAqLLO19:1=> At$$	MM4 5.25  QVVX&% !* 	d0v!%AAv00 "  1s   +D;D"D"DDc                   sP   a  ] tR tRt o RtR t]R 4       tR t]R 4       t	Rt
V tR# )	ru   iP  zUsed when we are writing directly to disk without sizelimits,
this allows us to keep more simplified flows for executing,
monitoring, and collecting command output.
c                s    Wn         W n        R # r3   )processr2   )selfr   r2   s   &&&r   __init__ZFakeReader.__init__V  s    r   c                s    R # Fr   r   r   r   rz   ZFakeReader.is_fullZ  s    r   c                .    V P                   '       g   R # R# rI   r   r2   r   r   r   ry   ZFakeReader.get_contents^      r-#-r   c                s:    V P                   P                  4       R J # r3   )r   ra   r   r   r   rw   ZFakeReader.runninga  s    ||  "d**r   )r2   r   N)r   r   __qualname____firstlineno____doc__r   propertyrz   ry   rw   __static_attributes____classdictcell____classdict__   @r   ru   ru   P  s<     
  . + +r   ru   c                   sV   a a ] tR tRt oRtRtV 3R ltR tR t]	R 4       t
RtVtV ;t# )	rt   if  zrUsed to 'head' the command output (f_src) to a given size
without deadlocking sos. Takes a sizelimit value in MB.
c                s   < \         SV `  4        Wn        W n        VR ,          V n        W@n        RV n        V P                  4        R# )r(   TN)superr   r   r   	remainingr2   rw   start)r   r   r   r}   r2   r   s   &&&&&r   r   ZHeadReader.__init__m  s9    

"W,

r   c                sl   V P                   ^ 8  d   V P                  P                  \        V P                   V P                  4      4      pV'       g   M?V P
                  P                  V4       V ;P                   \        V4      ,          un         K  V P                  P                  4        RV n	        R# )zReads from the f_src (Popen stdout pipe) until we reach sizelimit.
once done, close f_src to signal the program that we are done.
FN)
r   r   r   ZminCOPY_BUFSIZEr   r   lenrn   rw   )r   ZbufrL   r   runZHeadReader.runv  st     nnq **//#dnnd6G6G"HICJJS!NNc#h&N

r   c                r   r   r   r   r   r   ry   ZHeadReader.get_contents  r   r   c                s     V P                   ^ 8*  # )r    )r   r   r   r   rz   ZHeadReader.is_full  s    ~~""r   )r2   r   r   r   rw   r(   )r   r   r   r   r   r   r   r   ry   r   rz   r   r   __classcell__r   r      @@r   rt   rt   f  s9      L. # # #r   rt   c                   sR   a a ] tR tRt oRtV 3R ltR tR t]R 4       t	Rt
VtV ;t# )rv   i  zUsed to tail the command output to a given size without deadlocking
sos.

Takes a sizelimit value in MB, and will compile stdout from Popen into a
string that is limited to the given sizelimit.
c                s  < \         SV `  4        Wn        W0n        R V n        RV n        V'       d*   VR,          p\        W P                  ,          4      V n        \        V P
                  R7      V n        RV n        V P                  4        R# )i   Nr(   )ZmaxlenT)
r   r   chanr2   	chunksizeslotsZintr   rw   r   )r   Zchannelr}   r2   r   s   &&&&r   r   ZTailReader.__init__  sf    	
!G+IY78DJ$**-


r   c                s      V P                   P                  V P                  4      pV'       g   MV P                  P	                  V4       KL  RV n        R#   \
        \        3 d     Li ; i)a<  Reads from the channel (pipe) that is the output pipe for a
called Popen. As we are reading from the pipe, the output is added
to a deque. After the size of the deque exceeds the sizelimit
earlier (older) entries are removed.

This means the returned output is chunksize-sensitive, but is not
really byte-sensitive.
FN)r   r   r   r   rr   Z
ValueErrorr$   rw   )r   rE   rL   r   r   ZTailReader.run  sZ    		yy~~dnn5

!!$'  G$ 		s   -A A A+*A+c                s   V P                   '       d   \        P                  ! R4       K*  V P                  '       g#   RP	                  R V P
                   4       4      # RP	                  R V P
                   4       4      # )z-Returns the contents of the deque as a stringr`   rI   c              3   sD   "   T F  qP                  R R4      x  K  	  R# 5i)r   ZignoreN)Zdecoder5   ZlnrL   r   r8   *TailReader.get_contents.<locals>.<genexpr>  s     M*B99Wh77*s    r   c              3   s$   "   T F  qx  K  	  R # 5ir3   r   r   rL   r   r8   r     s     0ZrZs   )rw   rc   rd   r2   rB   r   r   r   r   ry   ZTailReader.get_contents  sT     lllJJt{{{77M$**MMMxx0TZZ000r   c                sn    V P                   '       g   R# \        V P                  4      V P                   8H  # )z?Checks if the deque is full, implying that output was truncatedF)r   r   r   r   r   r   rz   ZTailReader.is_full  s'     zzz4::$**,,r   )r2   r   r   r   rw   r   )r   r   r   r   r   r   r   ry   r   rz   r   r   r   r   r   r   rv   rv     s2     *1 - - -r   rv   c                   sB   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
r	   i  zProvides a list of modules that can be imported in a package.
Importable modules are located along the module __path__ list and modules
are files that end in .py.
c                s    Wn         R# )z_package is a package module
import my.package.module
helper = ImporterHelper(my.package.module)Npackage)r   r   r&   r   r   ZImporterHelper.__init__  s	     r   c                s    \         P                  P                  V4      p\         P                  P                  V4      w  r4V# )z-Returns the plugin module name given the path)r   r>   ZbasenameZsplitext)r   r>   ZbaserC   r   s   &&   r   _plugin_nameZImporterHelper._plugin_name  s1    ww%''""4(r   c                s    V Uu. uF6  pR V9  g   K  VP                  R4      '       g   K%  V P                  V4      NK8  	  ppVP                  4        V# u upi )r   z.py)Zendswithr   Zsort)r   Zlist_Zpluginpluginsr   r   _get_plugins_from_listZ%ImporterHelper._get_plugins_from_list  s`    !&K!&v . -39??53I -4$$V,!& 	 K 		Ks   	AAAc                s    \         P                  P                  V4      '       d1   \        \	        R V4      4      pV P                  V4      pV'       d   V# . # )z*.py)r   r>   r   ZlistrD   r   )r   r>   Zpy_filesZpnamesr   r   _find_plugins_in_dirZ#ImporterHelper._find_plugins_in_dir  sC    77>>$D./H00:F	r   c                s    . pV P                   P                   FJ  p\        P                  P	                  V4      '       g   K*  VP                  V P                  V4      4       KL  	  V# )zIReturns the list of importable modules in the configured python
package. )r   Z__path__r   r>   r   rG   r   )r   r   r>   r0   r   get_modulesZImporterHelper.get_modules  sN     LL))Dww}}T""t88>? * r   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r	     s(     
 r   c                   s2   a  ] tR tRt o R tR tR tRtV tR# )r   i  c                s     Wn         . V n        R # r3   )tmp_dirfiles)r   r   r&   r   r   ZTempFileUtil.__init__  s    
r   c                s    \         P                  ! V P                  R 7      w  r\        P                  ! VR4      pV P
                  P                  W#34       V# )rj   zw+)rs   Zmkstempr   r   Zfdopenr   rr   )r   Zfdr/   Zfobjr,   r   newZTempFileUtil.new  sA    $$6	yyT"

5-(r   c                s    V P                    F=  w  r VP                  4        VP                  4         \        P
                  ! V4       K?  	  . V n         R #   \         d     L1i ; i  \         d     Ki  i ; ir3   )r   r   rn   r   r   Zunlink)r   r/   r   r0   r   cleanZTempFileUtil.clean   sj    

HE				%  # 
  
  s"    AA(A%$A%(A76A7)r   r   N)	r   r   r   r   r   r   r   r   r   r   r   r   r   r     s      r   c                   s    ] tR tRtRtR# )r
   i  r   N)r   r   r   r   r   r   r   r   r
   r
     s    r   )TIMEOUT_DEFAULTr	   r
   r   r   r=   r'   rD   r   rH   r   rR   r   r   r   r   r   r   r   r   r   r   rx   r   )T)r.   )NNr3   r   )i   NN)rS   )Kr   rZ   r   r   Z
subprocessr   r   r   ZloggingrA   r|   rp   rq   rs   Z	threadingrc   r%   r   Z
contextlibr   Zcollectionsr   Zpackaging.versionr   r   r   Zpkg_resourcesZ	getLoggerr   r9   r:   r;   Z__file__ZAttributeErrorZtextwrapr   ZmsgZwarningr   Z__all__r   r   r   r'   r-   r1   r=   rD   rH   rR   rX   r   rx   r   r   r   r>   r   r   r   r   r   r   r@   r   r   r   ru   ZThreadrt   rv   r	   r   r{   r
   r   r   r   <module>r      s   
 
 	  * *         	   ,8  	B	x(I 8"	%.D+,		@, -<E"&d"'4#(e4Qh'T*H: /1gg 0/005" "
( -/ 31l+ +,"#!! "#J9-!! 9-x) )X :	g 	g  ,++, 	^$ BC
 KK"T#re<=R@ABs$   E( +E< (E98E9</F/.F/