o
    j                     @   s\   d dl Z d dlmZmZmZmZ d dlmZmZm	Z	 d dl
mZ d dlZG dd deZdS )    N)CallableIterableListOptional)CompleteEvent	Completer
Completion)Documentc                   @   sv   e Zd ZdZ					ddedeeg ee f  deeegef  de	d	ed
dfddZ
deded
ee fddZdS )PathCompletera  
	Complete for Path variables.

	:param get_paths: Callable which returns a list of directories to look into
					  when the user enters a relative path.
	:param file_filter: Callable which takes a filename and returns whether
						this file should show up in the completion. ``None``
						when no filtering has to be done.
	:param min_input_len: Don't do autocompletion when the input string is shorter.
	FNr   only_directoriesget_current_dirsfile_filtermin_input_len
expanduserreturnc                 C   s2   || _ |pdd | _|pdd | _|| _|| _d S )Nc                   S   s   dgS )N. r   r   r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/msldap/examples/utils/completers.py<lambda>   s    z(PathCompleter.__init__.<locals>.<lambda>c                 S   s   dS )NTr   )_r   r   r   r      s    )r   r   r   r   r   )selfr   r   r   r   r   r   r   r   __init__   s
   
zPathCompleter.__init__documentcomplete_eventc              
   c   s    |j }t|| jk rd S z!|  }|D ]}||r+|t|d  }t|d|dV  qW d S  tyE } zt  W Y d }~d S d }~ww )Nr   )display)	text_before_cursorlenr   r   
startswithr   	Exception	traceback	print_exc)r   r   r   textdirnamesdirname
completioner   r   r   get_completions   s    
	zPathCompleter.get_completions)FNNr   F)__name__
__module____qualname____doc__boolr   r   r   strintr   r	   r   r   r   r&   r   r   r   r   r
      s.    

r
   )ostypingr   r   r   r   prompt_toolkit.completionr   r   r   prompt_toolkit.documentr	   r   r
   r   r   r   r   <module>   s    