U
    ÉZj°%  ã                   @   sd   d dl Z d dlZd dlmZ ddlmZ e jG dd„ dƒƒZG dd„ deƒZ	G d	d
„ d
ee	d�Z
dS )é    N)ÚAnyé   )ÚPacketTypesc                   @   sŽ   e Zd ZdZd!eeedœdd„Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zeedœdd„ƒZd S )"Ú
ReasonCodezªMQTT version 5.0 reason codes class.

    See ReasonCode.names for a list of possible numeric values along with their
    names and the packets to which they apply.

    ÚSuccesséÿÿÿÿ)Ú
packetTypeÚaNameÚ
identifierc              -   C   sÒ  || _ tjtjtjtjtjtjtjgtj	gtj
gdœdtj
gidtj
gidtj	gidtjtjgidtjgidtjgidtjgid	tjtjtjtj
tjtj	gid
tjtj	gidtjtj	gidtjtjtjtj
tjtj	gidtjgidtjgidtjgidtjtjtjtj
tjtj	gidtjgidtjtj	gidtjgidtj	gidtjtj	gidtj	gidtj	gidtj
tjtj	gidtjtjtjtj	gidtjtjtj
tjgidtjtjgidtj	gidtj	gidtjtj	gidtj	gid tjtjtjtj
tj	gid!tj	gid"tjtjtj	gid#tjtj	gid$tjtj	gid%tjtj	gid&tjtj	gid'tj
tj	gid(tjtj	gid)tj	gid*tj
tj	gid+tj
tj	gid,œ+| _|d-k�rÀ|tj	k�r´|d.k�r´d/}|  |¡ n|| _|  ¡  d0S )1a¯  
        packetType: the type of the packet, such as PacketTypes.CONNECT that
            this reason code will be used with.  Some reason codes have different
            names for the same identifier when used a different packet type.

        aName: the String name of the reason code to be created.  Ignored
            if the identifier is set.

        identifier: an integer value of the reason code to be created.

        )r   úNormal disconnectionzGranted QoS 0zGranted QoS 1zGranted QoS 2zDisconnect with will messagezNo matching subscriberszNo subscription foundzContinue authenticationzRe-authenticatezUnspecified errorzMalformed packetzProtocol errorzImplementation specific errorzUnsupported protocol versionzClient identifier not validzBad user name or passwordzNot authorizedzServer unavailablezServer busyZBannedzServer shutting downzBad authentication methodzKeep alive timeoutzSession taken overzTopic filter invalidzTopic name invalidzPacket identifier in usezPacket identifier not foundzReceive maximum exceededzTopic alias invalidzPacket too largezMessage rate too highzQuota exceededzAdministrative actionzPayload format invalidzRetain not supportedzQoS not supportedzUse another serverzServer movedz!Shared subscription not supportedzConnection rate exceededzMaximum connect timez&Subscription identifiers not supportedz#Wildcard subscription not supported)+r   r   é   é   é   é   é   é   é€   é�   é‚   éƒ   é„   é…   é†   é‡   éˆ   é‰   éŠ   é‹   éŒ   é�   éŽ   é�   é�   é‘   é’   é“   é”   é•   é–   é—   é˜   é™   éš   é›   éœ   é�   éž   éŸ   é    é¡   é¢   r   r   r   N)r   r   ZCONNACKZPUBACKZPUBRECZPUBRELZPUBCOMPZUNSUBACKZAUTHZ
DISCONNECTZSUBACKÚnamesÚsetÚvalueÚgetName)Úselfr   r	   r
   © r:   úX/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/paho/mqtt/reasoncodes.pyÚ__init__!   sô       þü



ÿ



  þ
ÿ
ÿ   þ



  þ



ÿ

ÿ ÿÿ ÿÿ
ÿ



  ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿÿ
ÿ
ÿ·L
zReasonCode.__init__c                    sV   || j krt|ƒ‚| j | ‰ ‡ ‡fdd„ˆ  ¡ D ƒ}t|ƒdkrNtd|›�ƒ‚|d S )zô
        Get the reason code string name for a specific identifier.
        The name can vary by packet type for the same identifier, which
        is why the packet type is also required.

        Used when displaying the reason code.
        c                    s   g | ]}ˆˆ | kr|‘qS r:   r:   )Ú.0Úname©r5   r   r:   r;   Ú
<listcomp>Ž   s      z*ReasonCode.__getName__.<locals>.<listcomp>r   z!Expected exactly one name, found r   )r5   ÚKeyErrorÚkeysÚlenÚ
ValueError)r9   r   r
   Únamelistr:   r?   r;   Ú__getName__ƒ   s    

zReasonCode.__getName__c                 C   sP   | j  ¡ D ]2}|| j |  ¡ kr
| j| j | | kr
|  S q
td|› �ƒ‚dS )zÁ
        Get the numeric id corresponding to a reason code name.

        Used when setting the reason code for a packetType
        check that only valid codes for the packet are set.
        zReason code name not found: N)r5   rB   r   rA   )r9   r>   Úcoder:   r:   r;   ÚgetId“   s
    
zReasonCode.getIdc                 C   s   |   |¡| _d S ©N)rH   r7   )r9   r>   r:   r:   r;   r6       s    zReasonCode.setc                 C   s&   |d }|   | j|¡}|  |¡| _dS )Nr   r   )rF   r   rH   r7   )r9   ÚbufferÚcr>   r:   r:   r;   Úunpack£   s    zReasonCode.unpackc                 C   s   |   | j| j¡S )zVReturns the reason code name corresponding to the numeric value which is set.
        )rF   r   r7   ©r9   r:   r:   r;   r8   ©   s    zReasonCode.getNamec                 C   sD   t |tƒr| j|kS t |tƒr*|t| ƒkS t |tƒr@| j|jkS dS )NF)Ú
isinstanceÚintr7   Ústrr   ©r9   Úotherr:   r:   r;   Ú__eq__®   s    



zReasonCode.__eq__c                 C   s.   t |tƒr| j|k S t |tƒr*| j|jk S tS rI   )rN   rO   r7   r   ÚNotImplementedrQ   r:   r:   r;   Ú__lt__·   s
    


zReasonCode.__lt__c                 C   s@   zt j| j }W n tk
r(   d}Y nX d|› d|  ¡ ›d�S )NÚUnknownzReasonCode(z, ú))r   ZNamesr   Ú
IndexErrorr8   )r9   Zpacket_namer:   r:   r;   Ú__repr__¾   s
    
zReasonCode.__repr__c                 C   s   |   ¡ S rI   ©r8   rM   r:   r:   r;   Ú__str__Æ   s    zReasonCode.__str__c                 C   s   |   ¡ S rI   rZ   rM   r:   r:   r;   ÚjsonÉ   s    zReasonCode.jsonc                 C   s   t | jgƒS rI   )Ú	bytearrayr7   rM   r:   r:   r;   ÚpackÌ   s    zReasonCode.pack)Úreturnc                 C   s
   | j dkS )Nr   )r7   rM   r:   r:   r;   Ú
is_failureÏ   s    zReasonCode.is_failureN)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rO   rP   r<   rF   rH   r6   rL   r8   rS   rU   rY   r[   r\   r^   ÚpropertyÚboolr`   r:   r:   r:   r;   r      s   b	r   c                   @   s   e Zd Zeedœdd„ZdS )Ú_CompatibilityIsInstance)rR   r_   c                 C   s
   t |tƒS rI   )rN   r   rQ   r:   r:   r;   Ú__instancecheck__Õ   s    z*_CompatibilityIsInstance.__instancecheck__N)ra   rb   rc   r   rf   rh   r:   r:   r:   r;   rg   Ô   s   rg   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚReasonCodesc                    s"   t jdtdd� tƒ j||Ž d S )Nz<ReasonCodes is deprecated, use ReasonCode (singular) insteadr   )ÚcategoryÚ
stacklevel)ÚwarningsÚwarnÚDeprecationWarningÚsuperr<   )r9   ÚargsÚkwargs©Ú	__class__r:   r;   r<   Ú   s
    þzReasonCodes.__init__)ra   rb   rc   r<   Ú__classcell__r:   r:   rr   r;   ri   Ù   s   ri   )Ú	metaclass)Ú	functoolsrl   Útypingr   Zpackettypesr   Útotal_orderingr   Útyperg   ri   r:   r:   r:   r;   Ú<module>   s    <