§
    ¯eîiØ  ã                   ól   — d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 d„ Z
d	„ Zd
„ Z	 	 dd„ZdS )zCSome general file utilities used that can be used by the Cloud SDK.é    )Úabsolute_import)Údivision)Úunicode_literalsN)Úencoding)Ú	platformsc                  ó@   — t          j        t          j        d¦  «        S )z5Returns properly encoded system PATH variable string.ÚPATH)Úencoding_utilÚGetEncodedValueÚosÚenviron© ó    úV/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/fire/console/files.pyÚ_GetSystemPathr      s   € å	Ô	&¥r¤z°6Ñ	:Ô	:Ð:r   c                 óô  — t          |t          ¦  «        r"t          d                     |¦  «        ¦  «        ‚|D ]½}|                     t
          j        ¦  «        D ]›}|                     d¦  «        }t
          j         	                    t
          j         
                    || ¦  «        |z   ¦  «        }t
          j                             |¦  «        r%t          j        |t
          j        ¦  «        r|c c S ŒœŒ¾dS )a}  Internal function to a find an executable.

  Args:
    executable: The name of the executable to find.
    path: A list of directories to search separated by 'os.pathsep'.
    pathext: An iterable of file name extensions to use.

  Returns:
    str, the path to a file on `path` with name `executable` + `p` for
      `p` in `pathext`.

  Raises:
    ValueError: invalid input.
  zr_FindExecutableOnPath(..., pathext='{0}') failed because pathext must be an iterable of strings, but got a string.ú"N)Ú
isinstanceÚstrÚ
ValueErrorÚformatÚsplitr   ÚpathsepÚstripÚpathÚnormpathÚjoinÚisfileÚaccessÚX_OK)Ú
executabler   ÚpathextÚextÚ	directoryÚfulls         r   Ú_FindExecutableOnPathr&   !   sæ   € õ  ��ÑÔð 2Ý
ð !ç!'¢¨¡¤ñ2ô 2ð 2ð
 ð ð €cØ—Z’Z¥¤
Ñ+Ô+ð ð ˆ	à—/’/ #Ñ&Ô&€iÝŒW×Ò�bœgŸlšl¨9°jÑAÔAÀCÑGÑHÔH€då	Œ�Š˜Ñ	Ô	ð ¥"¤)¨Dµ"´'Ñ":Ô":ð Øˆˆˆˆˆøðð 
ˆr   c                 ó4   — | t           j        j        k    rdS dS )N)z.exez.cmdz.batz.comz.ps1)Ú z.sh)r   ÚOperatingSystemÚWINDOWS)Úplatforms    r   Ú_PlatformExecutableExtensionsr,   B   s   € Ø•Ô*Ô2Ò2Ð2Ø3Ð3àˆ;r   Fc                 ó¼  — |sGt           j                             | ¦  «        d         r"t          d                     | ¦  «        ¦  «        ‚t           j                             | ¦  «        r"t          d                     | ¦  «        ¦  «        ‚|€t          ¦   «         }n|}|�|n*t          t          j	         
                    ¦   «         ¦  «        }t          | ||¦  «        S )a$  Searches for `executable` in the directories listed in `path` or $PATH.

  Executable must not contain a directory or an extension.

  Args:
    executable: The name of the executable to find.
    path: A list of directories to search separated by 'os.pathsep'.  If None
      then the system PATH is used.
    pathext: An iterable of file name extensions to use.  If None then
      platform specific extensions are used.
    allow_extensions: A boolean flag indicating whether extensions in the
      executable are allowed.

  Returns:
    The path of 'executable' (possibly with a platform-specific extension) if
    found and executable, None if not found.

  Raises:
    ValueError: if executable has a path or an extension, and extensions are
      not allowed, or if there's an internal error.
  é   zWFindExecutableOnPath({0},...) failed because first argument must not have an extension.zQFindExecutableOnPath({0},...) failed because first argument must not have a path.)r   r   Úsplitextr   r   Údirnamer   r,   r   r)   ÚCurrentr&   )r!   r   r"   Úallow_extensionsÚeffective_pathÚeffective_pathexts         r   ÚFindExecutableOnPathr5   I   sõ   € ð0 
ð P�bœg×.Ò.¨zÑ:Ô:¸1Ô=ð PÝ
ð <ß<BºFÀ:Ñ<NÔ<NñPô Pð Põ „W‡_‚_�ZÑ Ô ð JÝ
ð 6ß6<²f¸ZÑ6HÔ6HñJô Jð Jð 
€\Ý#Ñ%Ô%€N€Nà€NØ")Ð"5�w�wÝ9Ý$Ô4×<Ò<Ñ>Ô>ñ@ô @ð õ 
˜z¨>Ø0ñ
2ô 
2ð 2r   )NNF)Ú__doc__Ú
__future__r   r   r   r   Úfire.consoler   r
   r   r   r&   r,   r5   r   r   r   ú<module>r9      sÅ   ðð  JÐ Ià &Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à 	€	€	€	à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø "Ð "Ð "Ð "Ð "Ð "ð;ð ;ð ;ð
ð ð ðBð ð ð 9=Ø*/ð)2ð )2ð )2ð )2ð )2ð )2r   