a }|ägã@sndZddlZddlmZddlmZddlmZddlm Z e  e ¡Z e ee dœdd „Ze ed œd d „ZdS) zPlugin utilities.éN)ÚList)Úutil)Úos)ÚSTANDARD_BINARY_DIRS)ÚpathÚreturncCsBtj |¡}g}|r>| |¡tj |¡\}}||dkrq>q|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Ú_©rú8/usr/lib/python3.9/site-packages/certbot/plugins/util.pyÚ get_prefixes s   r)ÚcmdrcCs’tjd}g}tD]$}||vr|tj|7}| |¡qt|ƒr`t d|tj |¡¡|tjd<t   |¡rndSt|ƒrzdnd}t d|||¡dS)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ÚjoinrZ exe_exists)rrZaddedÚdZexpandedrrrÚ path_surgery#s$   ÿ  ÿr)Ú__doc__ZloggingÚtypingrZcertbotrZcertbot.compatrZcertbot.compat.miscrZ getLoggerÚ__name__rÚstrrÚboolrrrrrÚs