
    F-Ph                       U d Z ddlmZ ddlZddlmZ ddlZddlZddlmZ  G d d          Z	ej
                            d          r6	 ddlZn# e$ r  ej        d	           Y nw xY w e	            Zd
ed<   ddZdS ddZdZdS )a  Allow bash-completion for argparse with argcomplete if installed.

Needs argcomplete>=0.5.6 for python 3.2/3.3 (older versions fail
to find the magic string, so _ARGCOMPLETE env. var is never set, and
this does not need special code).

Function try_argcomplete(parser) should be called directly before
the call to ArgumentParser.parse_args().

The filescompleter is what you normally would use on the positional
arguments specification, in order to get "dirname/" after "dirn<TAB>"
instead of the default "dirname ":

   optparser.add_argument(Config._file_or_dir, nargs='*').completer=filescompleter

Other, application specific, completers should go in the file
doing the add_argument calls as they need to be specified as .completer
attributes as well. (If argcomplete is not installed, the function the
attribute points to will not be used).

SPEEDUP
=======

The generic argcomplete script for bash-completion
(/etc/bash_completion.d/python-argcomplete.sh)
uses a python program to determine startup script generated by pip.
You can speed up completion somewhat by changing this script to include
  # PYTHON_ARGCOMPLETE_OK
so the python-argcomplete-check-easy-install-script does not
need to be called to find the entry point of the code and see if that is
marked  with PYTHON_ARGCOMPLETE_OK.

INSTALL/DEBUGGING
=================

To include this support in another application that has setup.py generated
scripts:

- Add the line:
    # PYTHON_ARGCOMPLETE_OK
  near the top of the main python entry point.

- Include in the file calling parse_args():
    from _argcomplete import try_argcomplete, filescompleter
  Call try_argcomplete just before parse_args(), and optionally add
  filescompleter to the positional arguments' add_argument().

If things do not work right away:

- Switch on argcomplete debugging with (also helpful when doing custom
  completers):
    export _ARC_DEBUG=1

- Run:
    python-argcomplete-check-easy-install-script $(which appname)
    echo $?
  will echo 0 if the magic line has been found, 1 if not.

- Sometimes it helps to find early on errors using:
    _ARGCOMPLETE=1 _ARC_DEBUG=1 appname
  which should throw a KeyError: 'COMPLINE' (which is properly set by the
  global argcomplete script).
    )annotationsN)glob)Anyc                  $    e Zd ZdZdddZddZdS )FastFilesCompleterzFast file completer class.TdirectoriesboolreturnNonec                    || _         d S N)r   )selfr   s     T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/_pytest/_argcomplete.py__init__zFastFilesCompleter.__init__M   s    &    prefixstrkwargsr   	list[str]c                0   t           j        |dd          v r:t          t           j                            |          t           j        z             }nd}g }g }d|vrFd|vrB|r|d         t           j        k    r%|                    t          |dz                        |dz  }|                    t          |                     t          |          D ]C}t           j                            |          r|dz  }|	                    ||d                     D|S )N   r   *?z.*/)
osseplenpathdirnameextendr   sortedisdirappend)r   r   r   
prefix_dir
completionglobbedxs          r   __call__zFastFilesCompleter.__call__P   s   6VABBZRW__V44rv=>>JJJ
fF!2!2 4VBZ2611tFTM22333cMFtF||$$$ 	. 	.Aw}}Q Sa
n----r   N)T)r   r	   r
   r   )r   r   r   r   r
   r   )__name__
__module____qualname____doc__r   r)    r   r   r   r   J   sG        $$' ' ' ' '     r   r   _ARGCOMPLETEr   zFastFilesCompleter | Nonefilescompleterparserargparse.ArgumentParserr
   r   c                2    t          j        | d           d S )NF)always_complete_options)argcompleteautocompleter1   s    r   try_argcompleter8   m   s     GGGGGGr   c                    d S r   r.   r7   s    r   r8   r8   r   s    r   )r1   r2   r
   r   )r-   
__future__r   argparser   r   systypingr   r   environgetargcomplete.completersr5   ImportErrorexitr0   __annotations__r8   r.   r   r   <module>rD      sG  > > >@ # " " " " "        				 



             8 :>>.!! %%%%%   0B0B0D0DNDDDDH H H H H H
    NNNs   
A A'&A'