
    h                         d Z ddlZddlmZ ej
                  j                         rddlmZ nddl	mZ ed        Z
 G d de      Zy)z,
Tab completion for our interpreter prompt.
    N)uses_settings)	lru_cachec                 H   |j                  dg       }| |S | j                  dd      }|rN|j                         D ]:  }|j                  dd      d   j	                  d      }|j                  d|z         < n|j                  d	       | j                  d
d      }|rg|j                         D ]S  }|j                  dd      d   }|j                  d|z         |j                  d|z         |j                  d|z         U n|g dz  }d}|D ]O  \  }}| j                  |d      }|r%||j                         D 	cg c]  }	||	z   	 c}	z  }?|j                  |       Q |j                  di       }
|
j                         D ]  }|j                  d|z           |S c c}	w )z*
  Provides commands recognized by tor.
  autocompleteNz
info/names    r   *z
GETINFO %szGETINFO zconfig/namesz
GETCONF %sz
SETCONF %szRESETCONF %s)zGETCONF zSETCONF z
RESETCONF ))z
SETEVENTS zevents/names)zUSEFEATURE zfeatures/names)zSIGNAL zsignal/namesz
help.usagez/help )getget_info
splitlinessplitrstripappendkeys)
controllerconfigcommandsresultslineoptionoptionsprefixgetinfo_cmdvalue
usage_infocmds               g/var/www/betterdocs.net/sherlock_api/venv/lib/python3.12/site-packages/stem/interpreter/autocomplete.py_get_commandsr      s    ZZ+(O
 d3'""$ -zz#q!!$++C0foolV+,- OOJ
 5'""$ /zz#q!!$foolV+,oolV+,oonv-./ 66H
' % fk!!+t4Gw}}?e6E>??hoof zz,+*__ $cOOHsN#$ 
/ @s   =Fc                   2    e Zd Zd Z e       d        Zd Zy)Autocompleterc                 $    t        |      | _        y )N)r   	_commands)selfr   s     r   __init__zAutocompleter.__init__T   s    ":.DN    c                     |j                         }| j                  D cg c]$  }|j                         j                  |      s#|& c}S c c}w )z
    Provides autocompletion matches for the given text.

    :param str text: text to check for autocompletion matches with

    :returns: **list** with possible matches
    )lowerr"   
startswith)r#   textlowercase_textr   s       r   matcheszAutocompleter.matchesW   s:     ZZ\N>>TCSYY[-C-CN-SCTTTs   $AAc                 J    	 | j                  |      |   S # t        $ r Y yw xY w)a  
    Provides case insensetive autocompletion options, acting as a functor for
    the readlines set_completer function.

    :param str text: text to check for autocompletion matches with
    :param int state: index of result to be provided, readline fetches matches
      until this function provides None

    :returns: **str** with the autocompletion match, **None** if eithe none
      exists or state is higher than our number of matches
    N)r+   
IndexError)r#   r)   states      r   completezAutocompleter.completed   s-    \\$&& s    	""N)__name__
__module____qualname__r$   r   r+   r/    r%   r   r    r    S   s$    / ;
U 
Ur%   r    )__doc__stem.prereqstemstem.interpreterr   prereq_is_lru_cache_available	functoolsr   stem.util.lru_cacher   objectr    r3   r%   r   <module>r=      sI     *;;&&(!+ = =@!F !r%   