o
    LK&h  ã                   @   s:   d dl Z ddlmZ G dd„ deeƒZdddœdd	„ZdS )
é    Né   )ÚAutocommandErrorc                   @   s   e Zd ZdS )ÚAutomainRequiresModuleErrorN)Ú__name__Ú
__module__Ú__qualname__© r   r   úZ/var/www/html/venv/lib/python3.10/site-packages/setuptools/_vendor/autocommand/automain.pyr      s    r   r   ©ÚargsÚkwargsc                   sF   t | ƒrt| ƒ‚| dks| du rˆdu ri ‰‡ ‡fdd„}|S dd„ S )a­  
    This decorator automatically invokes a function if the module is being run
    as the "__main__" module. Optionally, provide args or kwargs with which to
    call the function. If `module` is "__main__", the function is called, and
    the program is `sys.exit`ed with the return value. You can also pass `True`
    to cause the function to be called unconditionally. If the function is not
    called, it is returned unchanged by the decorator.

    Usage:

    @automain(__name__)  # Pass __name__ to check __name__=="__main__"
    def main():
        ...

    If __name__ is "__main__" here, the main function is called, and then
    sys.exit called with the return value.
    Ú__main__TNc                    s   t  | ˆ i ˆ¤Ž¡ d S ©N)ÚsysÚexit©Úmainr
   r   r	   Úautomain_decorator6   s   z$automain.<locals>.automain_decoratorc                 S   s   | S r   r   r   r   r   r	   Ú<lambda>;   s    zautomain.<locals>.<lambda>)Úcallabler   )Úmoduler   r   r   r   r
   r	   Úautomain   s   r   )r   Úerrorsr   Ú	TypeErrorr   r   r   r   r   r	   Ú<module>   s   