�
N�g � � � d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ej e� Zde
dee
fd �Zd
e
defd�Zy)zPlugin utilities.� N)�List)�util)�os)�STANDARD_BINARY_DIRS�path�returnc �� � t j j | � }g }|rA|j |� t j j |� \ }}||d k( 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`
���)r r �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 � � t j d }g }t D ]. }||vs�|t j |z z
}|j |� �0 t |� rGt j d| t j j |� � |t j d< |