o
    i                  
   @   s   d Z ddlZddlZddlZddlmZ G dd deZdddZd	d
 Z	e
dkrJze	  W dS  eyI 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_specc                   @   s   e Zd ZdS )ArgcompleteMarkerNotFoundN)__name__
__module____qualname__ r   r   _/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/argcomplete/_check_module.pyr      s    r   Fc                 C   s  |  d}tt|D ]}td|d |d  }|d ur%|jd ur% nq|d u r3td|d |js:td|j	d u rQt|dkrNtd|d |jS t|j	dkr\tdt
jj|j	d g||d d  R  }t
j|rd}|r{d	}t
j||S |d
 S )N.   zno module named "{}"r   zcannot locate filez{} is not a packagezexpecting one search locationz__main__.pyz__init__.pyz.py)splitrangelenr   joinoriginr   formathas_locationsubmodule_search_locationsospathisdir)namereturn_packagenamespackage_name_boundary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   main0   s"   r'   __main__)F)__doc__r   r   r!   importlib.utilr   RuntimeErrorr   r   r'   r   eexitstrr   r   r   r   <module>   s     	
