B
    ß%Q[w  ã               @   s\   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZ G dd„ deƒZd	S )
Ú
é    )Úlinesepé   )ÚSEQUENCE_TYPES)ÚLDAPKeyError)ÚlogÚlog_enabledÚERRORÚBASICÚPROTOCOLÚEXTENDEDc            
   @   s^   e Zd ZdZddddedddddf
dd„Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚAttrDefaq  Hold the definition of an attribute

    :param name: the real attribute name
    :type name: string
    :param key: the friendly name to use in queries and when accessing the attribute, default to the real attribute name
    :type key: string
    :param validate: called to check if the value in the query is valid, the callable is called with the value parameter
    :type validate: callable
    :param pre_query: called to transform values returned by search
    :type pre_query: callable
    :param post_query: called to transform values returned by search
    :type post_query: callable
    :param default: value returned when the attribute is absent (defaults to NotImplemented to allow use of None as default)
    :type default: string, integer
    :param dereference_dn: reference to an ObjectDef instance. When the attribute value contains a dn it will be searched and substituted in the entry
    :type dereference_dn: ObjectDef
    :param description: custom attribute description
    :type description: string
    :param mandatory: specify if attribute is defined as mandatory in LDAP schema
    :type mandatory: boolean
    NFc             C   sš   || _ |rd | ¡ ¡n|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _d | _|s`d | _n"t|tƒrvt|ƒ| _nt|gƒ| _ttƒr–ttd| ƒ d S )NÚ zinstantiated AttrDef: <%r>)ÚnameÚjoinÚsplitÚkeyÚvalidateÚ	pre_queryÚ
post_queryÚdefaultÚdereference_dnÚdescriptionÚ	mandatoryÚsingle_valueÚoid_infoÚother_namesÚ
isinstancer   Úsetr   r
   r   )Úselfr   r   r   r   r   r   r   r   r   r   Úalias© r!   úYC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-6i93dh7p\ldap3\ldap3\abstract\attrDef.pyÚ__init__9   s$    
zAttrDef.__init__c             C   s  | j r"dd | jgt| j ƒ ¡ n| j}|| j| jkr:dnd| j d 7 }|| jtkrZdndt| jƒ 7 }|| jd krzdndt| jƒ 7 }|| j	d kršdndt| j	ƒ 7 }|| j
s¶dnd	t| j
ƒ 7 }|| jsÒdnd
t| jƒ 7 }| j�rx(t| jƒ t¡D ]}|td | 7 }qüW |S )NzATTR: z, r   z [ú]z - default: z - mandatory: z - single_value: z - dereference_dn: z - description: z  )r   r   r   Úlistr   r   ÚNotImplementedÚstrr   r   r   r   r   r   r   )r   ÚrÚliner!   r!   r"   Ú__repr__P   s    ("   zAttrDef.__repr__c             C   s   |   ¡ S )N)r*   )r   r!   r!   r"   Ú__str__]   s    zAttrDef.__str__c             C   s   t |tƒr| j|jkS dS )NF)r   r   r   )r   Úotherr!   r!   r"   Ú__eq__`   s    
zAttrDef.__eq__c             C   s   t |tƒr| j|jk S dS )NF)r   r   r   )r   r,   r!   r!   r"   Ú__lt__f   s    
zAttrDef.__lt__c             C   s   | j rt| j ƒS t| ƒS d S )N)r   ÚhashÚid)r   r!   r!   r"   Ú__hash__l   s    
zAttrDef.__hash__c             C   sL   t | dƒr:|dkr:d| }ttƒr0ttd|| ƒ t|ƒ‚nt | ||¡ d S )Nr   zkey '%s' already setz%s for <%s>)Úhasattrr   r	   r   r   ÚobjectÚ__setattr__)r   r   ÚvalueÚerror_messager!   r!   r"   r4   r   s    
zAttrDef.__setattr__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r#   r*   r+   r-   r.   r1   r4   r!   r!   r!   r"   r   "   s   r   N)r:   Úosr   r   r   Zcore.exceptionsr   Z	utils.logr   r   r	   r
   r   r   r3   r   r!   r!   r!   r"   Ú<module>   s
    