File: //usr/lib/python3/dist-packages/certbot/_internal/display/__pycache__/completer.cpython-310.pyc
o
6��a� � @ sz d Z ddlZddlmZ ddlmZ ddlmZ zddlZW n ey3 ddlm m
mZ Y nw G dd� d�ZdS )z8Provides Tab completion when prompting users for a path.� N)�Callable)�Iterator)�Optionalc @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
S )� Completera/ Provides Tab completion when prompting users for a path.
This class is meant to be used with readline to provide Tab
completion for users entering paths. The complete method can be
passed to readline.set_completer directly, however, this function
works best as a context manager. For example:
with Completer():
raw_input()
In this example, Tab completion will be available during the call to
raw_input above, however, readline will be restored to its previous
state when exiting the body of the with statement.
c C s | | | d S �N� ��selfr r �E/usr/lib/python3/dist-packages/certbot/_internal/display/completer.py�__init__ s zCompleter.__init__c C s$ |dkrt �|d �| _t| jd�S )a( Provides path completion for use with readline.
:param str text: text to offer completions for
:param int state: which completion to return
:returns: possible completion for text or ``None`` if all
completions have been returned
:rtype: str
r �*N)�glob�iglob�_iter�next)r �text�stater r r
�complete$ s zCompleter.completec C sZ t �� | _t �� | _t �| j� t �d� t jd ur&dt jv r&t � d� d S t � d� d S )Nz
;�libeditzbind ^I rl_completez
tab: complete)
�readline�
get_completer�_original_completer�get_completer_delims�_original_delims�
set_completerr �set_completer_delims�__doc__�parse_and_bindr r r r
� __enter__3 s
zCompleter.__enter__c C s t �| j� t �| j� d S r )r r r r r )r �unused_type�unused_value�unused_tracebackr r r
�__exit__A s zCompleter.__exit__N)�__name__�
__module__�__qualname__r r r r r"