o
    VÌh‹
  ã                   @  s^   d dl mZ d dlmZ d dlmZ d dlmZ er&d dlm	Z	 d dl
mZ G dd„ dƒZd	S )
é    )Úannotations)Údefaultdict)ÚTYPE_CHECKING)ÚCleoCommandNotFoundError)ÚApplication)ÚCommandc                   @  sZ   e Zd ZdZ		dd dd„Zed!dd„ƒZed"dd„ƒZd#dd„Zd$dd„Z	d%dd„Z
dS )&ÚApplicationDescriptionÚ_globalNFÚapplicationr   Ú	namespaceú
str | NoneÚshow_hiddenÚboolÚreturnÚNonec                 C  s0   || _ || _|| _i | _i | _i | _|  ¡  d S ©N)Ú_applicationÚ
_namespaceÚ_show_hiddenÚ_namespacesÚ	_commandsÚ_aliasesÚ_inspect_application)Úselfr
   r   r   © r   ú|/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/cleo/descriptors/application_description.pyÚ__init__   s   zApplicationDescription.__init__ú%dict[str, dict[str, str | list[str]]]c                 C  ó   | j S r   )r   ©r   r   r   r   Ú
namespaces    ó   z!ApplicationDescription.namespacesúdict[str, Command]c                 C  r   r   )r   r   r   r   r   Úcommands$   r!   zApplicationDescription.commandsÚnameÚstrr   c                 C  s0   || j v r
| j | S || jv r| j| S t|ƒ‚r   )r   r   r   )r   r$   r   r   r   Úcommand(   s
   



zApplicationDescription.commandc                 C  s–   d }| j r| j | j ¡}| j |¡}|  |¡D ]1\}}g }|D ] \}}|jr)|jr*q|j|kr5|| j|< n|| j|< | 	|¡ q||dœ| j
|< qd S )N)Úidr#   )r   r   Úfind_namespaceÚallÚ_sort_commandsr$   Úhiddenr   r   Úappendr   )r   r   Úall_commandsr#   Únamesr$   r&   r   r   r   r   /   s   

òz+ApplicationDescription._inspect_applicationr#   ú+list[tuple[str, list[tuple[str, Command]]]]c                 C  sV   t tƒ}| ¡ D ]\}}| j |d¡pd}||| |< qdd„ | ¡ D ƒ}t| ¡ ƒS )z5
        Sorts command in alphabetical order
        é   r	   c                 S  s   i | ]\}}|t | ¡ ƒ“qS r   )ÚsortedÚitems)Ú.0r   r#   r   r   r   Ú
<dictcomp>Q   s    ÿÿz9ApplicationDescription._sort_commands.<locals>.<dictcomp>)r   Údictr2   r   Úextract_namespacer1   )r   r#   Únamespaced_commandsr$   r&   ÚkeyÚnamespaced_commands_listr   r   r   r*   F   s   þz%ApplicationDescription._sort_commands)NF)r
   r   r   r   r   r   r   r   )r   r   )r   r"   )r$   r%   r   r   )r   r   )r#   r"   r   r/   )Ú__name__Ú
__module__Ú__qualname__ÚGLOBAL_NAMESPACEr   Úpropertyr    r#   r&   r   r*   r   r   r   r   r      s    ü

r   N)Ú
__future__r   Úcollectionsr   Útypingr   Úcleo.exceptionsr   Úcleo.applicationr   Úcleo.commands.commandr   r   r   r   r   r   Ú<module>   s    