HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/argcomplete/__pycache__/__init__.cpython-39.pyc
a

�R_|�@sNddlmZmZmZmZddlZddlZddlZddlZddl	m
Z
mZddl
mZmZmZmZmZddl
mZmZddlmZmZmZmZddlmZd	ejvZejad
d�Z dZ!d
Z"ej#ej$ej%ej&ej'ej(ej)fZ*ej+dd��Z,ej+dd��Z-Gdd�de.�Z/ddd�Z0dd�Z1Gdd�de2�Z3Gdd�de3�Z4e3�Z5de5_6dd�Z7dS) �)�absolute_import�division�print_function�unicode_literalsN�)�
completers�my_shlex)�
USING_PYTHON2�str�sys_encoding�
ensure_str�ensure_bytes)�FilesCompleter�SuppressCompleter)�IntrospectiveArgumentParser�action_is_satisfied�action_is_open�action_is_greedy)�	shellcodeZ
_ARC_DEBUGcGs(tr$trdd�|D�}t|dti�dS)NcSs"g|]}t|t�rt|�n|�qS�)�
isinstancer
r
��.0�xrr�8/usr/lib/python3.9/site-packages/argcomplete/__init__.py�
<listcomp>�zdebug.<locals>.<listcomp>�file)�_DEBUGr	�print�debug_stream��argsrrr�debugsr#�O�Pccs2tj}ttjd�t_zdVW|t_n|t_0dS�N�w)�sys�stdout�open�os�devnull)r)rrr�mute_stdout%s
r-ccsFtj}ttjd�t_zdVWtj��|t_ntj��|t_0dSr&)r(�stderrr*r+r,�close)r.rrr�mute_stderr.s
�
r0c@seZdZdS)�ArgcompleteExceptionN)�__name__�
__module__�__qualname__rrrrr18sr1c	s�durt|��tj|dd��d�_tj�dd��_g����fdd�}z^���}|�jkrlddd�dfWS�j	�
��kr�td|dj�j
d	��||�WS��|�WqHty�td�jd
j�j
d	���j	�
��kr�|�j�YSd}t|��YqH0qHdS)NT)�posixZ_ARGCOMPLETE_COMP_WORDBREAKS�cs�t|���j��}t�jttf�r:�j�jvr:|d7}|t|�kr\td���	|�d}|d|�||d�}}d}�jdur��j�j
vr��j}|||��jfS)NrzIn trailing whitespacer6)�len�instream�tellr�stater
�bytesZ
whitespacer#�appendZquotes�last_wordbreak_pos)�wordZ
point_in_word�prefix�suffixZprequote�Zlexer�point�wordsrr�
split_wordCs
zsplit_line.<locals>.split_wordr>zsplit, lexer state: '{s}')�sz#split (lexer stopped, state: '{s}')zcUnexpected internal state. Please report this bug at https://github.com/kislyuk/argcomplete/issues.)r7�shlexZwhitespace_splitr+�environ�getZ
wordbreaksZ	get_token�eofr8r9r#�formatr:r<�
ValueError�tokenr1)�linerBrDr>�msgrrAr�
split_line;s*

rOcCs
|�|�S�N��
startswith)�
completionr?rrr�default_validatorksrTc@s�eZdZdZddddde�dfdd�Zdejddddde�fdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
edd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZdS)#�CompletionFindera
    Inherit from this class if you wish to override any of the stages below. Otherwise, use
    ``argcomplete.autocomplete()`` directly (it's a convenience instance of this class). It has the same signature as
    :meth:`CompletionFinder.__call__()`.
    NTFcCs^||_||_||_|durt}||_||_d|_i|_||_|durTt	j
�d�dk}||_dS)NFZ_ARGCOMPLETE_SUPPRESS_SPACE�1)
�_parser�always_complete_options�excluderT�	validator�print_suppressed�
completing�_display_completions�default_completerr+rGrH�append_space)�self�argument_parserrXrYrZr[r^r_rrr�__init__tszCompletionFinder.__init__c
	s^|j|||||||	d�dtjvr&dSzt�dd�aWntjaYn0t�|dur�tj�d�}
|
dur�td�	|
��t
|
d�}|dur�zt�d	d�}Wntd
�|d�Yn0tj�dd
��t��dkr�tdj	�d��|d�tj�d����r$t��dk�r$tdj	�d��|d�tjd}ttjd�}t
|�}t||�\}
}}}}ttjd�d}||d�}|�r�|d|jjv�r�d|v�r�|�|�dd�d�td�	|�d�	|�d�	|
�d�	|�d�	|�d|�|�|||
|�}��r"�fdd�|j��D����fdd�|D�}td |�|���|��t��|��t��|d�dS)!a�
        :param argument_parser: The argument parser to autocomplete on
        :type argument_parser: :class:`argparse.ArgumentParser`
        :param always_complete_options:
            Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
            been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
            suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
            with no long variant will be suggested. If ``short``, short options and long options with no short variant
            will be suggested.
        :type always_complete_options: boolean or string
        :param exit_method:
            Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
            perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
        :type exit_method: callable
        :param exclude: List of strings representing options to be omitted from autocompletion
        :type exclude: iterable
        :param validator:
            Function to filter all completions through before returning (called with two string arguments, completion
            and prefix; return value is evaluated as a boolean)
        :type validator: callable
        :param print_suppressed:
            Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
        :type print_suppressed: boolean
        :param append_space:
            Whether to append a space to unique matches. The default is ``True``.
        :type append_space: boolean

        .. note::
            If you are not subclassing CompletionFinder to override its behaviors,
            use ``argcomplete.autocomplete()`` directly. It has the same signature as this method.

        Produces tab completions for ``argument_parser``. See module docs for more info.

        Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
        added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
        their execution is otherwise desirable.
        )rXrYrZr[r_r^Z_ARGCOMPLETEN�	r'Z_ARGCOMPLETE_STDOUT_FILENAMEzUsing output file {}�wb�z)Unable to open fd 8 for writing, quittingrZ_ARGCOMPLETE_IFS�z%Invalid value for IFS, quitting [{v}])�vZ_ARGCOMPLETE_DFSz%Invalid value for DFS, quitting [{v}]Z	COMP_LINEZ
COMP_POINTr�=z
LINE: {!r}z
POINT: {!r}z
PREQUOTE: {!r}z
PREFIX: {!r}z
SUFFIX: {!r}z
WORDS:cs0i|](\}}|D]}||r&|��d�nd�qqS)� r6��replace)r�key�valueZkey_part)�ifsrr�
<dictcomp>�s�z-CompletionFinder.__call__.<locals>.<dictcomp>cs$g|]}��|��|�pdf��qS�r6)�joinrH)rrl)�dfs�display_completionsrrr�rz-CompletionFinder.__call__.<locals>.<listcomp>z
Returning completions:)rbr+rG�fdopenr r(r.r#rHrJr*r7�intrrOrW�prefix_charsr<�split�_get_completionsr]�items�writerq�encoder�flush)r`rarX�exit_methodZ
output_streamrYrZr[r_r^�filenameZ	comp_lineZ
comp_point�cword_prequote�cword_prefix�cword_suffix�
comp_wordsr=�start�completionsr)rrrsrnr�__call__�sp(
�


"
�
�
zCompletionFinder.__call__c

Cs|��}t��}d|_tr(dd�|D�}z^td|dd��t��(|jj|dd�|d�}Wd�n1sp0Ytd|�Wn:t	y�}z"tdt
|�t|�d	�WYd}~n
d}~00d
|_d|vr�d
|_|�
|||t�}	|�|	�}	|�|	||�}	|	S)NTcSsg|]}t|��qSr)r
)rr>rrrrrz5CompletionFinder._get_completions.<locals>.<listcomp>zinvoking parser withr)�	namespacezparsed args:z

exceptionzwhile parsing argsFz--)�_patch_argument_parser�argparse�	Namespacer\r	r#r0rW�parse_known_args�
BaseException�typer
rX�collect_completions�filter_completions�quote_completions)
r`r�r�rr=�active_parsers�parsed_args�a�er�rrrrx�s&6,
z!CompletionFinder._get_completionscsFg|_g|_|���fdd���|j�td|j�td|j�|jS)a�
        Since argparse doesn't support much introspection, we monkey-patch it to replace the parse_known_args method and
        all actions with hooks that tell us which action was last taken or about to be taken, and let us have the parser
        figure out which subparsers need to be activated (then recursively monkey-patch those).
        We save all active ArgumentParsers to extract all their possible option names later.
        cs��j�|��j�|�t|t�r&dSd}tr6t|�}t|t|jfi�|_|j	D]>}t
|d�r`qPG��fdd�d|j�}|j|_|j|_
||_qPdS)NZ(MonkeyPatchedIntrospectiveArgumentParser�_orig_classcseZdZd��fdd�	ZdS)zPCompletionFinder._patch_argument_parser.<locals>.patch.<locals>.IntrospectActionNcs�td|�td||||�td|j�td|j��jsL|j||||d�njt|jtj�r�td��|j|d�|j||||d�n.|jtvr�|j	s��j
�|�|j||||d�dS)NzAction stub called onz	args:z	orig class:z	orig callable:)�
option_stringz:orig class is a subparsers action: patching and running itr)r#r��_orig_callabler\�
issubclassr��_SubParsersAction�_name_parser_map�safe_actions�option_strings�visited_positionalsr<)r`�parserr��valuesr���	completer�patchrrr�8s

zYCompletionFinder._patch_argument_parser.<locals>.patch.<locals>.IntrospectAction.__call__)N)r2r3r4r�rr�rr�IntrospectAction7sr�)r�r<r�rrr	r;r��	__class__�_actions�hasattrr�r�r�)r�Z	classname�actionr�r�rrr�%s


z6CompletionFinder._patch_argument_parser.<locals>.patchzActive parsers:zVisited positionals:)r�r�rWr#�r`rr�rr�s)
z'CompletionFinder._patch_argument_parserc
s�dd�}i}|j��D] }|j|}|�|g��|�q|��D]*}|||j|j��}|r@|j|j|<q@�fdd�|j��D�}	|	S)Ncst�fdd�|D��S)Nc3s|]}|���r|VqdSrPrQr�r?rr�	<genexpr>WrzVCompletionFinder._get_subparser_completions.<locals>.filter_aliases.<locals>.<genexpr>)�tuple)�aliasesr?rr�r�filter_aliasesVszCCompletionFinder._get_subparser_completions.<locals>.filter_aliasescsg|]}|���r|�qSrrQ)rZsubcmd�r�rrrcrz?CompletionFinder._get_subparser_completions.<locals>.<listcomp>)�choices�keys�
setdefaultr<�_get_subactions�dest�helpr])
r`r�r�r�Zaliases_by_parserrl�pr�Zsubcmd_with_aliasesr�rr�r�_get_subparser_completionsUs
z+CompletionFinder._get_subparser_completionscszt��dks|jdur*�fdd�|jD�Sdd�|jD�}dd�|jD�}|jdkr`|r\|S|S|jdkrv|rr|S|SgS)	NrTcs"g|]}t|����rt|��qSr�rrR�r�optr�rrrhrz5CompletionFinder._include_options.<locals>.<listcomp>cSs g|]}t|�dkrt|��qS���r7rr�rrrrircSs g|]}t|�dkrt|��qSr�r�r�rrrrjrZlongZshort)r7rXr�)r`r�r�Z	long_optsZ
short_optsrr�r�_include_optionsfs

z!CompletionFinder._include_optionscs�|j��fdd�|jD��g}|jD]b}|js^t|dd�}t|t�rP|��rPq&|jt	j
kr^q&|�||�slq&t|t	j�s&||�
|��7}q&|S)Ncs0g|](}|jrt�fdd�|jD��|jg�qS)c3s$|]}t|����rt|�VqdSrPr�rr�rrr�ss�zFCompletionFinder._get_option_completions.<locals>.<listcomp>.<genexpr>)r�r�r�)rr�r�rrrss
��z<CompletionFinder._get_option_completions.<locals>.<listcomp>r�)r]�updater�r[�getattrrr�suppressr�r��SUPPRESS�_action_allowedr�r�)r`r�r�Zoption_completionsr�r�rr�r�_get_option_completionsqs$
��
z(CompletionFinder._get_option_completionscCs(|j�|g�D]}||jvrdSqdS�NFT)Z_action_conflictsrH�_seen_non_default_actions)r�r��conflict_actionrrrr��s
z CompletionFinder._action_allowedc
s\tdjt|j�|jd���o*�d|jv�d��fdd�|jD�}|rxt|�dks\Jd��td	|dd
�i�_g}n"�r�d�vr���d�\�}�n|Sd}|p�|jD�]���js�t��r�d
}|s�t	��r�t��s�td��q�td��j
�t�dd�}	|	du�r@�jdu�r,t
�tj��s,t��j�}	nt
�tj��s@�j}	|	r�t
|	t��r\|	���r\q�t|	��rև�fdd�|	��||d�D�}
|
�r4||
7}t
|	tj��r��j��fdd�|
D��n�j�dd�|
D��n^td�td�D]L}|	��|�}|du�r�q4��|���r�j�|fdi�|�|��q��rL�fdd�|D�}td|�q�|S)NzActive actions (L={l}): {a})�lr�rr6csg|]}t|��r|�qSr)rr)�
isoptionalrrr�rz<CompletionFinder._complete_active_option.<locals>.<listcomp>rzexpect at most 1 greedy actionzResetting completions becausezmust consume the next argumentrhFTZSkippingzActivating completion forr�csg|]}��|��r|�qSr)rZ�r�c)r�r`rrr�s�)r?r�r�r�csg|]}|f�jg�qSr)r�r)�
active_actionrrr�rcSsg|]}|fdg�qSrprrrrrr�rzICompleter is not callable, trying the readline completer protocol insteadi'csg|]}�d|�qS)rhr)rrS)�optional_prefixrrr�rzCompletions:)r#rJr7Zactive_actionsrvr]�	partitionr�rrr�r�r�rr�r�rZChoicesCompleterr^rr��callabler��rangeZcompleterZr<)
r`r��next_positionalr�r�r�Zgreedy_actions�_Zcomplete_remaining_positionalsr�Zcompletions_from_callable�iZnext_completionr)r�r�r�r�r`r�_complete_active_option�sr


�
��
z(CompletionFinder._complete_active_optioncCs�g}|d|�|d}|d|�|js@t|�dkrP|d|jvrP||�||�7}|d|�|��}|d|�t|tj�r�||�||�7}|�	|||||�}|d|�|d|j
�|S)	a0
        Visits the active parsers and their actions, executes their completers or introspects them to collect their
        option strings. Returns the resulting completions as a list of strings.

        This method is exposed for overriding in subclasses; there is no need to use it directly.
        zall active parsers:���zactive_parser:rzoptional options:znext_positional:zactive options:zdisplay completions:)rXr7rvr��_get_next_positionalrr�r�r�r�r])r`r�r�r�r#r��
active_parserr�rrrr��s"

 

�
z$CompletionFinder.collect_completionscCsz|jd}|jd}|��}|s$dS||kr4|dSd}tt|��D]}|||krDqZqD|dt|�krv||dSdS)z>
        Get the next positional action if it exists.
        r�Nrr)r�r��_get_positional_actionsr�r7)r`r�Zlast_positionalZall_positionalsr�rrrr��s

z%CompletionFinder._get_next_positionalcs<dd�|D�}|jdur t�|_t|j���fdd�|D�S)a
        Ensures collected completions are Unicode text, de-duplicates them, and excludes those specified by ``exclude``.
        Returns the filtered completions as an iterable.

        This method is exposed for overriding in subclasses; there is no need to use it directly.
        cSsg|]}t|��qSr)rr�rrrrrz7CompletionFinder.filter_completions.<locals>.<listcomp>Ncs"g|]}|�vr��|�s|�qSr)�addr���seenrrr$r)rY�set)r`r�rr�rr�s



z#CompletionFinder.filter_completionscs�d}|dkr,�r"�fdd�|D�}|d7}n|dkr<|d7}tj�d�d	vrRd}n|d
krld}dd�|D�}|D]��fdd�|D�}qp|jr�d
}t|�dkr�|dd|vr�|dkr�|dd7<|S)a�
        If the word under the cursor started with a quote (as indicated by a nonempty ``cword_prequote``), escapes
        occurrences of that quote character in the completions, and adds the quote to the beginning of each completion.
        Otherwise, escapes all characters that bash splits words on (``COMP_WORDBREAKS``), and removes portions of
        completions before the first colon if (``COMP_WORDBREAKS``) contains a colon.

        If there is only one completion, and it doesn't end with a **continuation character** (``/``, ``:``, or ``=``),
        adds a space after the completion.

        This method is exposed for overriding in subclasses; there is no need to use it directly.
        �\r6csg|]}|�dd��qS)rNrr�)r=rrr:rz6CompletionFinder.quote_completions.<locals>.<listcomp>z();<>|&!`$* 	
"'�"z"`$!Z_ARGCOMPLETE_SHELL)ZtcshZfish�'cSsg|]}|�dd��qS)r�z'\''rjr�rrrrFrcsg|]}|��d���qS)r�rjr�)�charrrrIrz=/:rrr�ri)r+rGrHr_r7)r`r�rr=Z
special_charsZcontinuation_charsr)r�r=rr�&s(
z"CompletionFinder.quote_completionscsr|dkrRt��\}�}}}|�dtjd�|�|�||�}��fdd�|D�|_|t|j�krj|j|SdSdS)a�
        Alternate entry point for using the argcomplete completer in a readline-based REPL. See also
        `rlcompleter <https://docs.python.org/2/library/rlcompleter.html#completer-objects>`_.
        Usage:

        .. code-block:: python

            import argcomplete, argparse, readline
            parser = argparse.ArgumentParser()
            ...
            completer = argcomplete.CompletionFinder(parser)
            readline.set_completer_delims("")
            readline.set_completer(completer.rl_complete)
            readline.parse_and_bind("tab: complete")
            result = input("prompt> ")

        (Use ``raw_input`` instead of ``input`` on Python 2, or use `eight <https://github.com/kislyuk/eight>`_).
        rcs g|]}�|t��d��qSrP)r7)r�match�r��textrrrmrz0CompletionFinder.rl_complete.<locals>.<listcomp>N)rO�insertr(�argvrxZ_rl_matchesr7)r`r�r:rr�r�Zfirst_colon_pos�matchesrr�r�rl_completeVs
zCompletionFinder.rl_completecCsdd�|j��D�S)a�
        This function returns a mapping of option names to their help strings for displaying to the user

        Usage:

        .. code-block:: python

            def display_completions(substitution, matches, longest_match_length):
                _display_completions = argcomplete.autocomplete.get_display_completions()
                print("")
                if _display_completions:
                    help_len = [len(x) for x in _display_completions.values() if x]

                    if help_len:
                        maxlen = max([len(x) for x in _display_completions])
                        print("\n".join("{0:{2}} -- {1}".format(k, v, maxlen)
                                        for k, v in sorted(_display_completions.items())))
                    else:
                        print("    ".join(k for k in sorted(_display_completions)))
                else:
                    print(" ".join(x for x in sorted(matches)))

                import readline
                print("cli /> {0}".format(readline.get_line_buffer()), end="")
                readline.redisplay()

            ...
            readline.set_completion_display_matches_hook(display_completions)

        cSsi|]\}}d�|�|�qS)ri)rq)r�krgrrrro�rz<CompletionFinder.get_display_completions.<locals>.<dictcomp>)r]ryr�rrr�get_display_completionstsz(CompletionFinder.get_display_completions)r2r3r4�__doc__rrbr+�_exitr�rxr�r�r�r��staticmethodr�r�r�r�r�r�r�r�rrrrrUns,�
�
y<
P0rUc@seZdZedd��ZdS)�ExclusiveCompletionFindercCs<t�||�sdStjtjf}|j|vr*dS||jvr8dSdSr�)rUr�r��
_AppendAction�_AppendConstActionr�r�)r�r�Zappend_classesrrrr��s

z)ExclusiveCompletionFinder._action_allowedN)r2r3r4r�r�rrrrr��sr�zV Use this to access argcomplete. See :meth:`argcomplete.CompletionFinder.__call__()`. cGstdg|�Rdti�dS)z�
    Prints **args** to standard error when running completions. This will interrupt the user's command line interaction;
    use it to indicate an error condition that is preventing your completer from working.
    �
rN)rr r!rrr�warn�sr�)N)8Z
__future__rrrrr+r(r��
contextlibr6rrrF�compatr	r
rrr
rrZmy_argparserrrrZshell_integrationrrGrr.r r#ZBASH_FILE_COMPLETION_FALLBACKZBASH_DIR_COMPLETION_FALLBACK�_StoreAction�_StoreConstAction�_StoreTrueAction�_StoreFalseActionr�r��_CountActionr��contextmanagerr-r0�	Exceptionr1rOrT�objectrUr�Zautocompleter�r�rrrr�<module>sF 
	�

	
0+