HOME


Mini Shell 1.0
DIR: /snap/certbot/4557/lib64/python3.12/site-packages/certbot/plugins/__pycache__/
Upload File :
Current File : //snap/certbot/4557/lib64/python3.12/site-packages/certbot/plugins/__pycache__/util.cpython-312.pyc
�


N�g���dZddlZddlmZddlmZddlmZddlm	Z	eje�Zde
dee
fd	�Zd
e
defd�Zy)zPlugin utilities.�N)�List)�util)�os)�STANDARD_BINARY_DIRS�path�returnc���tjj|�}g}|rA|j|�tjj	|�\}}||dk(r	|S|r�A|S)a�Retrieves all possible path prefixes of a path, in descending order
    of length. For instance:

      * (Linux) `/a/b/c` returns `['/a/b/c', '/a/b', '/a', '/']`
      * (Windows) `C:\a\b\c` returns `['C:\a\b\c', 'C:\a\b', 'C:\a', 'C:']`

    :param str path: the path to break into prefixes

    :returns: all possible path prefixes of given path in descending order
    :rtype: `list` of `str`
    ���)rr�normpath�append�split)r�prefix�prefixes�_s    ��/build/snapcraft-certbot-2c33630aaf29c47357e5a1683f659d3d/parts/certbot/install/lib/python3.12/site-packages/certbot/plugins/util.py�get_prefixesrsb���W�W�
�
�d�
#�F��H�
�������G�G�M�M�&�)�	����X�b�\�!���O�
��O��cmdc��tjd}g}tD].}||vs�|tj|zz
}|j	|��0t|�rGtjd|tjj|��|tjd<tj|�ryt|�rdnd}tjd|||�y)z�Attempt to perform PATH surgery to find cmd

    Mitigates https://github.com/certbot/certbot/issues/1833

    :param str cmd: the command that is being searched for in the PATH

    :returns: True if the operation succeeded, False otherwise
    �PATHz6Can't find %s, attempting PATH mitigation by adding %sTz	 expanded�z*Failed to find executable %s in%s PATH: %sF)r�environr�pathsepr�any�logger�debug�joinr�
exe_exists)rr�added�d�expandeds     r�path_surgeryr"#s����:�:�f��D��E�
!����D�=��B�J�J��N�"�D��L�L��O��
�5�z����M��"�*�*�/�/�%�0�	2�!��
�
�6�����s���!�%�j�{�b�H�
�L�L�=�s��4�!�r)�__doc__�logging�typingr�certbotr�certbot.compatr�certbot.compat.miscr�	getLogger�__name__r�strr�boolr"�rr�<module>r.sS�������4�	��	�	�8�	$���s��t�C�y��.�c��d�r