+
    õÉÍj-  ã                   ó  € R 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]P                  ! ]
4      tRR ltRR ltR t]P                  RR l4       tRR ltR 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R ltRR ltR# )z£Module mimics some of the behaviors of the builtin :mod:`shutil`.

It adds logging to all operations and abstracting some other useful shell
commands (functions).
Nc                ó~   € \        V \        4      '       d   V P                  R4      p \        P                  ! WR7      # )z¢Split the string s using shell-like syntax.

Args:
    s (str): String to split
    posix (bool): Use posix split

Returns:
    list of str: List of string parts
úutf-8)Úposix)Ú
isinstanceÚbytesÚdecodeÚshlexÚsplit)Úsr   s   &&ÚH/opt/data/home/.local/lib/python3.14/site-packages/tea/shell/__init__.pyr	   r	      s.   € ô �!”U×ÒØ�H‰H�WÓˆÜ�;Š;�qÔ&Ð&ó    c              #  óŽ  a"  € \        S4      '       d   V3R lpMV3R lp\        P                  ! \        P                  P	                  V 4      4       Fj  w  rVp. pV'       d   VP                  V4       V'       d   VP                  V4       V! V4       F$  p	\        P                  P                  WY4      x € K&  	  Kl  	  R# 5i)ax  Recursive search function.

Args:
    path (str): Path to search recursively
    matcher (str or callable): String pattern to search for or function
        that returns True/False for a file argument
    dirs (bool): if True returns directories that match the pattern
    files(bool): if True returns files that match the patter

Yields:
    str: Found files and directories
c                 ó.   <€ \        \        SV 4      4      # ©N)ÚlistÚfilter©ÚitemsÚmatchers   &€r   Ú	fnmatcherÚsearch.<locals>.fnmatcher2   s   ø€ Üœ˜w¨Ó.Ó/Ð/r   c                 ó2   <€ \         P                  ! V S4      # r   )Úfnmatchr   r   s   &€r   r   r   7   s   ø€ Ü—>’> %¨Ó1Ð1r   N)ÚcallableÚosÚwalkÚpathÚabspathÚextendÚjoin)
r   r   ÚdirsÚfilesr   ÚrootÚdirectoriesÚ	filenamesÚto_matchÚitems
   &f&&      r   Úsearchr'   #   sŠ   øé € ô �×Òö	0õ
	2ô )+¯ª´·±·±ÀÓ0EÖ(FÑ$ˆ˜9ØˆßØ�O‰O˜KÔ(ßØ�O‰O˜IÔ&Ù˜hÖ'ˆDÜ—'‘'—,‘,˜tÓ*Ô*ó (ó )Gùs   ƒA:CÁ>ACc                ó�  € \         P                  P                  V 4      p \        P	                  RV ,          4        \         P                  P                  V 4      '       g   \        P                  RV 4       R# \         P                  ! V 4       R#   \         d)   p\        P                  RT : RT: 24        Rp?R# Rp?ii ; i)zVChange the current working directory.

Args:
    directory (str): Directory to go to.
zchdir -> %sz-chdir -> %s failed! Directory does not exist!FTz	chdir -> z	 failed! N)	r   r   r   ÚloggerÚinfoÚisdirÚerrorÚchdirÚ	Exception)Ú	directoryÚes   & r   r-   r-   D   sˆ   € ô —‘—‘ 	Ó*€IÜ
‡K�K� 	Õ)Ô*ð
Ü�w‰w�}‰}˜Y×'Ò'Ü�L‰LØ?Àôñ Ü
�Š�ÔÙøÜô Ü�Š³ºAÐ>Ô?Ýûðús#   ½$B Á"B Á:B ÂCÂC Ã Cc              #  óF  "  € \         P                  ! 4       p\         P                  P                  V 4      p \         P                  P	                  V 4      '       g   V'       dq   \        V 4      '       d`   \        P                  RV 4       \         P                  ! V 4        Rx € \        P                  RV 4       \         P                  ! V4       R# \        P                  RV 4       Rx € R#   \        P                  RT 4       \         P                  ! T4       i ; i5i)a%  Context object for changing directory.

Args:
    directory (str): Directory to go to.
    create (bool): Create directory if it doesn't exists.

Usage::

    >>> with goto(directory) as ok:
    ...     if not ok:
    ...         print 'Error'
    ...     else:
    ...         print 'All OK'
z
goto -> %sTz
goto <- %sz:goto(%s) - directory does not exist, or cannot be created.FN)	r   Úgetcwdr   r   r+   Úmkdirr)   r*   r-   )r/   ÚcreateÚcurrents   && r   Úgotor6   Y   s·   é € ô" �iŠi‹k€GÜ—‘—‘ 	Ó*€Iä	‡w�w‡}�}�Y×Ò§F¬u°Y×/?Ò/?Ü�‰�L )Ô,Ü
�Š�Ôð	ØŠJä�K‰K˜ iÔ0Ü�HŠH�WÖä�‰ØKØô	
ð Œøô �K‰K˜ iÔ0Ü�HŠH�WÕüs%   ‚A!D!Á$=D!Â"C0 Â&A
D!Ã0.DÄD!c                óL  € \         P                  RV ,          4       \        P                  P	                  V 4      '       d   V'       g   R# \        V 4      '       g   R#  \        P                  ! W4       R#   \         d!    \         P                  RT ,          4        R# i ; i)a†  Make a directory.

Create a leaf directory and all intermediate ones.
Works like ``mkdir``, except that any intermediate path segment (not just
the rightmost) will be created if it does not exist. This is recursive.

Args:
    path (str): Directory to create
    mode (int): Directory mode
    delete (bool): Delete directory/file if exists

Returns:
    bool: True if succeeded else False
z	mkdir: %sTFzFailed to mkdir: %s)	r)   r*   r   r   r+   ÚremoveÚmakedirsr.   Ú	exception)r   ÚmodeÚdeletes   &&&r   r3   r3   }   st   € ô ‡K�K�˜dÕ"Ô#Ü	‡w�w‡}�}�T×ÒßÙÜ�d�|Š|ÙðÜ
�Š�DÔÙøÜô Ü×ÑÐ.°Õ5Ô6Úðús   Á A8 Á8'B#Â"B#c                 óØ   € \         P                  P                  V 4      p\         P                  P                  V4      '       g&   \	        V4      '       g   \        R V,          4      hR# R# )zFailed to create "%s"N)r   r   Údirnamer+   r3   r.   )ÚdestinationÚdestdirs   & r   Ú__create_destdirrA   š   sK   € Ü�g‰g�o‰o˜kÓ*€GÜ�7‰7�=‰=˜×!Ò!Ü�W�~Š~ÜÐ3°gÕ=Ó>Ð>ñ ñ "r   c                óä   € \         P                  RV : RV: 24        \        V4       \        P                  ! W4       R#   \
         d#   p\         P                  RYT4        Rp?R# Rp?ii ; i)a  Copy data and mode bits ("cp source destination").

The destination may be a directory.

Args:
    source (str): Source file (file to copy).
    destination (str): Destination file or directory (where to copy).

Returns:
    bool: True if the operation is successful, False otherwise.
z
copyfile: ú -> Tz$copyfile: %s -> %s failed! Error: %sNF)r)   r*   rA   ÚshutilÚcopyr.   r,   ©Úsourcer?   r0   s   && r   Ú
__copyfilerH   ¡   sY   € ô ‡K‚K«²Ð<Ô=ðÜ˜Ô%Ü�Š�FÔ(ÙøÜô Ü�‰Ø2°FÈô	
õ ûð	úó   Ÿ!A ÁA/ÁA*Á*A/c                óä   € \         P                  RV : RV: 24        \        V4       \        P                  ! W4       R#   \
         d#   p\         P                  RYT4        Rp?R# Rp?ii ; i)a$  Copy data and all stat info ("cp -p source destination").

The destination may be a directory.

Args:
    source (str): Source file (file to copy).
    destination (str): Destination file or directory (where to copy).

Returns:
    bool: True if the operation is successful, False otherwise.
zcopyfile2: rC   Tz%copyfile2: %s -> %s failed! Error: %sNF)r)   r*   rA   rD   Úcopy2r.   r,   rF   s   && r   Ú__copyfile2rL   ¹   sY   € ô ‡K‚K«²Ð=Ô>ðÜ˜Ô%Ü�Š�VÔ)ÙøÜô Ü�‰Ø3°VÈ!ô	
õ ûð	úrI   c                óæ   € \         P                  RV : RV: 24        \        V4       \        P                  ! WV4       R#   \
         d#   p\         P                  RYT4        Rp?R# Rp?ii ; i)a&  Copy a directory tree recursively using copy2().

The destination directory must not already exist.

If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
links are copied.

Args:
    source (str): Source directory (directory to copy).
    destination (str): Destination directory (where to copy).
    symlinks (bool): Follow symbolic links.

Returns:
    bool: True if the operation is successful, False otherwise.
z
copytree: rC   Tz$copytree: %s -> %s failed! Error: %sNF)r)   r*   rA   rD   Úcopytreer.   r:   )rG   r?   Úsymlinksr0   s   &&& r   Ú
__copytreerP   Ñ   s]   € ô$ ‡K‚K«²Ð<Ô=ðÜ˜Ô%Ü�Š˜¨XÔ6ÙøÜô Ü×ÑØ2°FÈô	
õ ûð	ús   Ÿ"A ÁA0ÁA+Á+A0c                óx   € \         P                  P                  V 4      '       d   \        W4      # \	        W4      # )zÚCopy file or directory.

Args:
    source (str): Source file or directory
    destination (str): Destination file or directory (where to copy).

Returns:
    bool: True if the operation is successful, False otherwise.
)r   r   r+   rP   rL   ©rG   r?   s   &&r   rE   rE   ï   s-   € ô 
‡w�w‡}�}�V×ÒÜ˜&Ó.Ð.ä˜6Ó/Ð/r   c                óh   € \         P                   ! V 4       F  p\        W!4      '       d   K   R# 	  R# )zïCopy all file found by glob.glob(pattern) to destination directory.

Args:
    pattern (str): Glob pattern
    destination (str): Path to the destination directory.

Returns:
    bool: True if the operation is successful, False otherwise.
FT)ÚglobrE   ©Úpatternr?   r&   s   && r   ÚgcopyrW   ÿ   ó*   € ô —	’	˜'Ö"ˆÜ�D×&Ô&Úñ #ñ r   c                óâ   € \         P                  RV : RV: 24        \        V4       \        P                  ! W4       R#   \
         d"    \         P                  RT : RT: 24        R# i ; i)a¨  Move a file or directory (recursively) to another location.

If the destination is on our current file system, then simply use
rename. Otherwise, copy source to the destination and then remove
source.

Args:
    source (str): Source file or directory (file or directory to move).
    destination (str): Destination file or directory (where to move).

Returns:
    bool: True if the operation is successful, False otherwise.
zMove: rC   TzFailed to Move: F)r)   r*   rA   rD   Úmover.   r:   rR   s   &&r   rZ   rZ     sV   € ô ‡K‚K£FªKÐ8Ô9ðÜ˜Ô%Ü�Š�FÔ(ÙøÜô Ü×Ò³vº{ÐKÔLÚðús   Ÿ!A Á(A.Á-A.c                óh   € \         P                   ! V 4       F  p\        W!4      '       d   K   R# 	  R# )zïMove all file found by glob.glob(pattern) to destination directory.

Args:
    pattern (str): Glob pattern
    destination (str): Path to the destination directory.

Returns:
    bool: True if the operation is successful, False otherwise.
FT)rT   rZ   rU   s   && r   Úgmover\   '  rX   r   c                óØ   € \         P                  RV ,          4        \        P                  ! V 4       R#   \         d)   p\         P                  RT : RT: 24        Rp?R# Rp?ii ; i)z›Delete a file.

Args:
    path (str): Path to the file that needs to be deleted.

Returns:
    bool: True if the operation is successful, False otherwise.
z
rmfile: %sTzrmfile: ú failed! Error: NF)r)   r*   r   r8   r.   r,   ©r   r0   s   & r   Ú__rmfiler`   7  sL   € ô ‡K�K�˜tÕ#Ô$ðÜ
�	Š	�$ŒÙøÜô Ü�Š³tºQÐ?Ô@Ýûðúó   ž6 ¶A)ÁA$Á$A)c                óØ   € \         P                  RV ,          4        \        P                  ! V 4       R#   \         d)   p\         P                  RT : RT: 24        Rp?R# Rp?ii ; i)z¶Recursively delete a directory tree.

Args:
    path (str): Path to the directory that needs to be deleted.

Returns:
    bool: True if the operation is successful, False otherwise.
z
rmtree: %sTzrmtree: r^   NF)r)   r*   rD   Úrmtreer.   r,   r_   s   & r   Ú__rmtreerd   I  sM   € ô ‡K�K�˜tÕ#Ô$ðÜ�Š�dÔÙøÜô Ü�Š³tºQÐ?Ô@Ýûðúra   c                óx   € \         P                  P                  V 4      '       d   \        V 4      # \	        V 4      # )zµDelete a file or directory.

Args:
    path (str): Path to the file or directory that needs to be deleted.

Returns:
    bool: True if the operation is successful, False otherwise.
)r   r   r+   rd   r`   )r   s   &r   r8   r8   [  s+   € ô 
‡w�w‡}�}�T×ÒÜ˜‹~Ðä˜‹~Ðr   c                óh   € \         P                   ! V 4       F  p\        V4      '       d   K   R# 	  R# )z«Remove all file found by glob.glob(pattern).

Args:
    pattern (str): Pattern of files to remove
Returns:
    bool: True if the operation is successful, False otherwise.
FT)rT   r8   )rV   r&   s   & r   Úgremoverg   j  s(   € ô —	’	˜'Ö"ˆÜ�d�|Œ|Úñ #ñ r   c                óþ   €  \         P                  ! WR7      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i  \         d"   p\        P                  RY4        Rp?R# Rp?ii ; i)z¾Read the content of the file.

Args:
    path (str): Path to the file
    encoding (str): File encoding. Default: utf-8

Returns:
    str: File content or empty string if there was an error
)ÚencodingNzread: %s failed. Error: %sÚ )ÚioÚopenÚreadr.   r)   r,   )r   ri   Úfr0   s   &&  r   rm   rm   x  sQ   € ðÜ�WŠW�T×-Õ-°Ø—6‘6“8÷ .×-×-Ó-ûäô Ü�‰Ð1°4Ô;Ýûðús1   ‚A ¡<±
A ¼A	ÁA ÁA ÁA<ÁA7Á7A<c                óB  € \         P                  P                  V 4      p V'       g>   \         P                  P                  V 4      '       d   \        P                  RV 4       R#  \        P                  RV 4       \        P                  ! V R4      ;_uu_ 4       p\        V\        4      '       g   VP                  V4      pVP                  V4       RRR4       R#   + '       g   i     R# ; i  \         d"   p\        P                  RY4        Rp?R# Rp?ii ; i)aƒ  Create a file at the given path if it does not already exists.

Args:
    path (str): Path to the file.
    content (str): Optional content that will be written in the file.
    encoding (str): Encoding in which to write the content.
        Default: ``utf-8``
    overwrite (bool): Overwrite the file if exists.

Returns:
    bool: True if the operation is successful, False otherwise.
ztouch: "%s" already existsFz	touch: %sÚwbNTztouch: %s failed. Error: %s)r   r   r   Úexistsr)   Úwarningr*   rk   rl   r   r   ÚencodeÚwriter.   r,   )r   Úcontentri   Ú	overwritern   r0   s   &&&&  r   Útouchrw   Š  sÃ   € ô �7‰7�?‰?˜4Ó €DßœŸ™Ÿ™¨×-Ò-Ü�‰Ð3°TÔ:Ùð	Ü�‰�K Ô&Ü�WŠW�T˜4× Ô  AÜ˜g¤u×-Ò-Ø!Ÿ.™.¨Ó2�Ø�G‰G�GÔ÷ !ñ ÷	 !Ö ñ ûÜô Ü�‰Ð2°DÔ<Ýûðús6   Á&5C2 Â9CÃC2 ÃC/	Ã)C2 Ã/C2 Ã2DÃ=DÄD)T)Ú*FT)F)ií  F)r   )rj   r   F) Ú__doc__r   rk   rT   r   rD   r   ÚloggingÚ
contextlibÚ	getLoggerÚ__name__r)   r	   r'   r-   Úcontextmanagerr6   r3   rA   rH   rL   rP   rE   rW   rZ   r\   r`   rd   r8   rg   rm   rw   © r   r   Ú<module>r€      s¬   ðñó 
Û 	Û Û Û Û Û Û ð 
×	Ò	˜8Ó	$€ô'ô+òBð* ×Ñó ó ð ôFò:?òò0ô0ò<0ò ò ò0ò ò$ò$òôö$r   