o
    aqeK                  	   @   s   d dl Z d dlmZmZ d dlmZ d dlmZmZm	Z	m
Z
mZmZmZ ddlmZ G dd dZG d	d
 d
eedZG dd dZG dd deZdeee	e f deeeef e	eeef  f fddZdeeef defddZdS )    N)ABCMetaabstractmethod)wraps)CallableIterableListSetUnionDictAny   )SlackObjectFormationErrorc                   @   s   e Zd Zdd ZdS )
BaseObjectc                 C   s   d| j j dS )N<slack.>)	__class____name__self r   [/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/__init__.py__str__
   s   zBaseObject.__str__N)r   
__module____qualname__r   r   r   r   r   r   	   s    r   c                   @   sT   e Zd Zeedee fddZdddZde	fddZ
de	fd	d
Zdd ZdS )
JsonObjectreturnc                 C   s   t  S )zOProvide a set of attributes of this object that will make up its JSON structure)setr   r   r   r   
attributes   s   zJsonObject.attributesNc                 C   s@   dd t | D D ]}t| |d}t|rt|dr|  q	dS )zY
        Raises:
          SlackObjectFormationError if the object was not valid
        c                 s   s    | ]
}| d s|V  qdS )__N)
startswith).0funcr   r   r   	<genexpr>   s    z+JsonObject.validate_json.<locals>.<genexpr>N	validator)dirgetattrcallablehasattr)r   	attributemethodr   r   r   validate_json   s   zJsonObject.validate_jsonc                    sV   dt tttf dt ttf ffdddtdtfdd  fdd	tjD S )
zw
        Construct a dictionary out of non-null keys (from attributes property)
        present on this object
        valuer   c                    sR   t | tr fdd| D S t| dd }|r't|r' fdd|   D S | S )Nc                    s   g | ]} |qS r   r   )r    vto_dict_compatibler   r   
<listcomp>'   s    zRJsonObject.get_non_null_attributes.<locals>.to_dict_compatible.<locals>.<listcomp>to_dictc                    s   i | ]	\}}| |qS r   r   )r    kr,   r-   r   r   
<dictcomp>+   s    zRJsonObject.get_non_null_attributes.<locals>.to_dict_compatible.<locals>.<dictcomp>)
isinstancelistr%   r&   r0   items)r+   r0   r-   r   r   r.   %   s   


z>JsonObject.get_non_null_attributes.<locals>.to_dict_compatiblekeyc                 S   s@   t | |d }|d u rdS t |dd d u}|rt|dkS |d uS )NF__len__r   )r%   len)r   r6   r+   has_lenr   r   r   is_not_empty1   s   z8JsonObject.get_non_null_attributes.<locals>.is_not_emptyc                    s(   i | ]} |r|t |d qS N)r%   )r    r6   r:   r   r.   r   r   r2   ;   s    z6JsonObject.get_non_null_attributes.<locals>.<dictcomp>)r	   dictr4   objectstrboolsortedr   r   r   r<   r   get_non_null_attributes   s
   (
z"JsonObject.get_non_null_attributesc                 G   s   |    |  S )a  
        Extract this object as a JSON-compatible, Slack-API-valid dictionary

        Args:
          *args: Any specific formatting args (rare; generally not required)

        Raises:
          SlackObjectFormationError if the object was not valid
        )r*   rB   )r   argsr   r   r   r0   A   s   
zJsonObject.to_dictc                 C   s*   |   }|rd| jj d| dS |  S )Nr   z: r   )rB   r   r   r   )r   
dict_valuer   r   r   __repr__N   s   zJsonObject.__repr__)r   N)r   r   r   propertyr   r   r?   r   r*   r=   rB   r0   rE   r   r   r   r   r      s    

"r   )	metaclassc                   @   s0   e Zd ZdefddZdeded fddZd	S )
JsonValidatormessagec                 C   s
   || _ dS )z
        Decorate a method on a class to mark it as a JSON validator. Validation
            functions should return true if valid, false if not.

        Args:
            message: Message to be attached to the thrown SlackObjectFormationError
        N)rI   )r   rI   r   r   r   __init__W   s   
zJsonValidator.__init__r!   r   ).Nc                    s    t   fdd}d|_|S )Nc                     s    | i |st jd S r;   )r   rI   )rC   kwargsr!   r   r   r   	wrapped_fb   s   
z)JsonValidator.__call__.<locals>.wrapped_fT)r   r#   )r   r!   rM   r   rL   r   __call__a   s   zJsonValidator.__call__N)r   r   r   r?   rJ   r   rN   r   r   r   r   rH   V   s    
rH   c                       s*   e Zd Zdedee f fddZ  ZS )EnumValidatorr(   enumc                    s    t  | dd|  d S )Nz0 attribute must be one of the following values: , )superrJ   join)r   r(   rP   r   r   r   rJ   l   s
   zEnumValidator.__init__)r   r   r   r?   r   rJ   __classcell__r   r   rT   r   rO   k   s    "rO   item_or_itemsr   c                    sD   z
 fdd| D W S  t y!   t| tr| j   Y S |  Y S w )a  
    Given a sequence (or single item), attempt to call the to_dict() method on each
    item and return a plain list. If item is not the expected type, return it
    unmodified, in case it's already a plain dict or some other user created class.

    Args:
      item_or_items: item(s) to go through
      format_args: Any formatting specifiers to pass into the object's to_dict
            method
    c                    s$   g | ]}t |tr|j  n|qS r   )r3   r   r0   )r    elemformat_argsr   r   r/      s    z extract_json.<locals>.<listcomp>)	TypeErrorr3   r   r0   )rV   rY   r   rX   r   extract_jsont   s   

r[   nameothersc                 C   sh   d|v r	| d t|dkr2d| }tt}t| tr$| j	j} |
d|  d| d dS dS )zPrints a warning message if the given 'others' is not empty.

    :param name: the object's name
    :param others: unknown fields
    :return: None
    typer   rQ   z!!! z's constructor args (z) were ignored.If they should be supported by this library, report this issue to the project :bow: https://github.com/slackapi/python-slackclient/issuesN)popr8   rS   keyslogging	getLoggerr   r3   r>   r   debug)r\   r]   r`   loggerr   r   r   show_unknown_key_warning   s   


re   )ra   abcr   r   	functoolsr   typingr   r   r   r   r	   r
   r   errorsr   r   r   rH   rO   r[   r?   r>   r=   re   r   r   r   r   <module>   s    $H	
