U
    >qa!                     @   s*   d Z ddlZddlmZ G dd dZdS )a  
*******************************************************************
  Copyright (c) 2017, 2019 IBM Corp.

  All rights reserved. This program and the accompanying materials
  are made available under the terms of the Eclipse Public License v2.0
  and Eclipse Distribution License v1.0 which accompany this distribution.

  The Eclipse Public License is available at
     http://www.eclipse.org/legal/epl-v10.html
  and the Eclipse Distribution License is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

  Contributors:
     Ian Craggs - initial implementation and/or documentation
*******************************************************************
    N   )PacketTypesc                   @   sb   e Zd ZdZ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S )ReasonCodeszMQTT version 5.0 reason codes class.

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

    Successc              -   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rd/}| | 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)
packetTyper   ZCONNACKZPUBACKZPUBRECZPUBRELZPUBCOMPZUNSUBACKZAUTHZ
DISCONNECTZSUBACKnamessetvaluegetName)selfr1   ZaName
identifier r8   X/var/www/html/flasktest/Project_env/lib/python3.8/site-packages/paho/mqtt/reasoncodes.py__init__    s       







  

   



  





  




  








L
zReasonCodes.__init__c                    sP   || j  kst|| j |   fdd  D }t|dksHt|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 r8   r8   ).0namer2   r1   r8   r9   
<listcomp>   s      z+ReasonCodes.__getName__.<locals>.<listcomp>r   r   )r2   keysAssertionErrorlen)r6   r1   r7   namelistr8   r=   r9   __getName__   s
    
zReasonCodes.__getName__c                 C   sV   d}| j  D ]2}|| j |  kr| j| j | | kr<|} qBq|dk	sRt||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.
        N)r2   r?   r1   r@   )r6   r<   r7   coder8   r8   r9   getId   s    zReasonCodes.getIdc                 C   s   |  || _d S N)rE   r4   )r6   r<   r8   r8   r9   r3      s    zReasonCodes.setc                 C   s<   |d }t jd dk rt|}| | j|}| || _dS )Nr      r   )sysversion_infoordrC   r1   rE   r4   )r6   buffercr<   r8   r8   r9   unpack   s    zReasonCodes.unpackc                 C   s   |  | j| jS )zVReturns the reason code name corresponding to the numeric value which is set.
        )rC   r1   r4   r6   r8   r8   r9   r5      s    zReasonCodes.getNamec                 C   sF   t |tr| j|kS t |tr,| jt| kS t |trB| j|jkS dS )NF)
isinstanceintr4   strr   )r6   otherr8   r8   r9   __eq__   s    



zReasonCodes.__eq__c                 C   s   |   S rF   r5   rN   r8   r8   r9   __str__   s    zReasonCodes.__str__c                 C   s   |   S rF   rT   rN   r8   r8   r9   json   s    zReasonCodes.jsonc                 C   s   t | jgS rF   )	bytearrayr4   rN   r8   r8   r9   pack   s    zReasonCodes.packN)r   r   )__name__
__module____qualname____doc__r:   rC   rE   r3   rM   r5   rS   rU   rV   rX   r8   r8   r8   r9   r      s   
b	r   )r\   rH   Zpackettypesr   r   r8   r8   r8   r9   <module>   s   