
    (\i%                         d dl Z d dlZd dlmZ ddlmZ e j                   G d d             Z G d de      Z	 G d	 d
ee	      Z
y)    N)Any   )PacketTypesc                   ~    e Zd ZdZddededefdZd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zedefd       Zy)
ReasonCodezMQTT 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.

    
packetTypeaName
identifierc                 j   || _         i dt        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  gt        j                  gt        j                  gdddt        j                  giddt        j                  giddt        j                  gid	d
t        j                  t        j                  giddt        j                  giddt        j                  giddt        j                  giddt        j                  t        j                  t        j                  t        j                  t        j                  t        j                  giddt        j                  t        j                  giddt        j                  t        j                  giddt        j                  t        j                  t        j                  t        j                  t        j                  t        j                  giddt        j                  giddt        j                  giddt        j                  gidd t        j                  t        j                  t        j                  t        j                  t        j                  t        j                  gid!d"t        j                  gii d#d$t        j                  t        j                  gid%d&t        j                  gid'd(t        j                  gid)d*t        j                  t        j                  gid+d,t        j                  gid-d.t        j                  gid/d0t        j                  t        j                  t        j                  gid1d2t        j                  t        j                  t        j                  t        j                  gid3d4t        j                  t        j                  t        j                  t        j                  gid5d6t        j
                  t        j                  gid7d8t        j                  gid9d:t        j                  gid;d<t        j                  t        j                  gid=d>t        j                  gid?d@t        j                  t        j                  t        j                  t        j                  t        j                  gidAdBt        j                  gidCdDt        j                  t        j                  t        j                  gidEt        j                  t        j                  gidFt        j                  t        j                  gidGt        j                  t        j                  gidHt        j                  t        j                  gidIt        j                  t        j                  gidJt        j                  t        j                  gidKt        j                  gidLt        j                  t        j                  gidMt        j                  t        j                  gidN	| _        |dOk(  r,|t        j                  k(  r|dPk(  rdQ}| j                  |       yR|| _        | j                          yR)Sa  
        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   )SuccessNormal disconnectionzGranted QoS 0r   zGranted QoS 1   zGranted QoS 2   zDisconnect with will message   zNo matching subscribers   zNo subscription found   zContinue authentication   zRe-authenticate   zUnspecified error   zMalformed packet   zProtocol error   zImplementation specific error   zUnsupported protocol version   zClient identifier not valid   zBad user name or password   zNot authorized   zServer unavailable   zServer busy   Banned   zServer shutting down   zBad authentication method   zKeep alive timeout   zSession taken over   zTopic filter invalid   zTopic name invalid   zPacket identifier in use   zPacket identifier not found   zReceive maximum exceeded   zTopic alias invalid   zPacket too large   zMessage rate too high   zQuota exceeded   zAdministrative action   z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   N)r   r   CONNACKPUBACKPUBRECPUBRELPUBCOMPUNSUBACKAUTH
DISCONNECTSUBACKnamessetvaluegetName)selfr   r	   r
   s       e/home/devuser/fomin/mqttuser/mqtt_project/myenv/lib/python3.12/site-packages/paho/mqtt/reasoncodes.py__init__zReasonCode.__init__!   s    %K
K//1C1C'..0B0BKDWDW'00+2B2BD *5)?)?(@"-"4"4!5	7K
 +"4"4!56K
 +"4"4!56K
 .1G1G0HIK
 *$$k&8&89;K
 (;+?+?*@AK
 *[-=-=,>?K
 "[%5%5$67K
 %(;(;[=O=O(3(:(:K<N<NP[PdPd(3(>(>(@ CK
" $&&(>(>?A#K
& "&&(>(>?A'K
* 1K4G4G4?4F4FHZHZ\g\n\n4?4H4H+J`J`4b e+K
0 0;3F3F2GH1K
2 /+2E2E1FG3K
4 -0C0C/DE5K
6 "[%8%8+:L:L%0%7%79K9K[MaMa%0%;%;%= @7K
< &)<)<(=>=K
> -+"5"5{7M7M!NO?K
@ ([0012AK
B (;+A+A*BCCK
D -&&(>(>?AEK
H &)?)?(@AIK
J &)?)?(@AKK
L (%%{';';[=S=STVMK
P &&&(:(:%%{'='=?@QK
V ,%%{'9'9%%{';';=>WK
\ /%%{':':;=]K
` ,{/E/E.FGaK
b '+*@*@)ABcK
d ${':':K<R<R&STeK
f )K,B,B+CDgK
h "[%8%8+:L:L%0%7%79K9K[McMc%e hiK
l )K,B,B+CDmK
n *%%{'9'9;;Q;QRToK
r )&&(>(>?A%&&(>(>?A&&&(>(>?A &&(>(>?A5%%{'='=>@,&&(>(>?A())*,:%%{'='=>@7%%{'='=>@SK

X [3338J.HHUO#DJLLN    c                     || j                   vrt        |      | j                   |   }|j                         D cg c]  }|||   v s| }}t        |      dk7  rt	        d|      |d   S c c}w )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.
        r   z!Expected exactly one name, found r   )rB   KeyErrorkeyslen
ValueError)rF   r   r
   rB   namenamelists         rG   __getName__zReasonCode.__getName__   s|     TZZ':&&

:&%*ZZ\OTZ5;5NDOOx=A@MNN{ Ps   A/A/c                     | j                   j                         D ]D  }|| j                   |   j                         v s#| j                  | j                   |   |   v sB|c S  t        d|       )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: )rB   rL   r   rK   )rF   rO   codes      rG   getIdzReasonCode.getId   sl     JJOO% 	 Dtzz$',,..??djj&6t&<<K	  5dV<==rI   c                 0    | j                  |      | _        y N)rT   rD   )rF   rO   s     rG   rC   zReasonCode.set   s    ZZ%
rI   c                 r    |d   }| j                  | j                  |      }| j                  |      | _        y)Nr   r   )rQ   r   rT   rD   )rF   buffercrO   s       rG   unpackzReasonCode.unpack   s4    1I3ZZ%
rI   c                 N    | j                  | j                  | j                        S )zVReturns the reason code name corresponding to the numeric value which is set.
        )rQ   r   rD   rF   s    rG   rE   zReasonCode.getName   s     <<rI   c                     t        |t              r| j                  |k(  S t        |t              r|t        |       k(  S t        |t              r| j                  |j                  k(  S y)NF)
isinstanceintrD   strr   rF   others     rG   __eq__zReasonCode.__eq__   sT    eS!::&&eS!CI%%eZ(::,,rI   c                     t        |t              r| j                  |k  S t        |t              r| j                  |j                  k  S t        S rV   )r^   r_   rD   r   NotImplementedra   s     rG   __lt__zReasonCode.__lt__   s>    eS!::%%eZ(::++rI   c                     	 t         j                  | j                     }d| d| j	                         dS # t        $ r d}Y $w xY w)NUnknownzReasonCode(z, ))r   Namesr   
IndexErrorrE   )rF   packet_names     rG   __repr__zReasonCode.__repr__   sO    	$%++DOO<K [MDLLN+=Q??  	$#K	$s   6 AAc                 "    | j                         S rV   rE   r\   s    rG   __str__zReasonCode.__str__       ||~rI   c                 "    | j                         S rV   ro   r\   s    rG   jsonzReasonCode.json   rq   rI   c                 .    t        | j                  g      S rV   )	bytearrayrD   r\   s    rG   packzReasonCode.pack   s    $**&&rI   returnc                      | j                   dk\  S )Nr   )rD   r\   s    rG   
is_failurezReasonCode.is_failure   s    zzT!!rI   N)r   r8   )__name__
__module____qualname____doc__r_   r`   rH   rQ   rT   rC   rZ   rE   rc   rf   rm   rp   rs   rv   propertyboolry    rI   rG   r   r      sy    `3 `s `3 `D >&=
@' "D " "rI   r   c                       e Zd ZdedefdZy)_CompatibilityIsInstancerb   rw   c                 "    t        |t              S rV   )r^   r   ra   s     rG   __instancecheck__z*_CompatibilityIsInstance.__instancecheck__   s    %,,rI   N)rz   r{   r|   r   r   r   r   rI   rG   r   r      s    -s -t -rI   r   c                        e Zd Z fdZ xZS )ReasonCodesc                 \    t        j                  dt        d       t        |   |i | y )Nz<ReasonCodes is deprecated, use ReasonCode (singular) insteadr   )category
stacklevel)warningswarnDeprecationWarningsuperrH   )rF   argskwargs	__class__s      rG   rH   zReasonCodes.__init__   s,    T'	
 	$)&)rI   )rz   r{   r|   rH   __classcell__)r   s   @rG   r   r      s    * *rI   r   )	metaclass)	functoolsr   typingr   packettypesr   total_orderingr   typer   r   r   rI   rG   <module>r      sQ   "    $ x" x" x"v-t -
**(@ *rI   