o
    ?@i8
                     @   s  d Z ddlZddlZddlZzddlmZ W n3 eyI   ddlZddl	m
Z
 ddlmZ e
dg dZ	dded	eje d
eje fddZY nw G dd deZdddZdd Zedkrze  W dS  ey Z zeee W Y dZ[dS dZ[ww dS )a  
Utility for locating a module (or package's __main__.py) with a given name
and verifying it contains the PYTHON_ARGCOMPLETE_OK marker.

The module name should be specified in a form usable with `python -m`.

Intended to be invoked by argcomplete's global completion function.
    N)	find_spec)
namedtuple)find_module
ModuleSpec)originhas_locationsubmodule_search_locationsnamepackagereturnc                 C   sZ   z	t | \}}}W n
 ty   Y dS w |du}|du r#td||gS |  t||dS )z-Minimal implementation as required by `find`.N)r   ImportErrorr   close)r	   r
   fpath_r    r   W/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/argcomplete/_check_module.pyr      s   r   c                   @   s   e Zd ZdS )ArgcompleteMarkerNotFoundN)__name__
__module____qualname__r   r   r   r   r   '   s    r   Fc                 C   s   |  d}t|d }|d u rtd|d |jstd|jd u r6t|dkr3td|d |jS t|jdkrAtdtj	j
|jd g|dd  R  }tj	|red}|r^d	}tj	
||S |d
 S )N.r   zno module named "{}"zcannot locate file   z{} is not a packagezexpecting one search locationz__main__.pyz__init__.pyz.py)splitr   r   formatr   r   lenr   osr   joinisdir)r	   return_packagenamesspecr   filenamer   r   r   find+   s&   

"r#   c                  C   s   zt jd } W n ty   tdw t| }zt|}W n ty)   tdw | |d}W d    n1 s<w   Y  d|vrItdd S )Nr   z$missing argument on the command linezcannot open filei   PYTHON_ARGCOMPLETE_OKzmarker not found)	sysargv
IndexErrorr   r#   tokenizeopenOSErrorread)r	   r"   fpheadr   r   r   mainB   s"   r.   __main__)N)F)__doc__r   r%   r(   importlib.utilr   r   typingtcollectionsr   impr   r   strOptionalRuntimeErrorr   r#   r.   r   eexitr   r   r   r   <module>   s>    	
