o
    ßý°jw  ã                   @   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 | _|s0d | _nt|tƒr;t|ƒ| _nt|gƒ| _ttƒrMttd| ƒ d S 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!   ú‰/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/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u r-dndt| jƒ 7 }|| jd u r=dndt| jƒ 7 }|| j	d u rMdndt| j	ƒ 7 }|| j
s[dnd	t| j
ƒ 7 }|| jsidnd
t| jƒ 7 }| jr‡t| jƒ t¡D ]
}|td | 7 }q||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__`   ó   
zAttrDef.__eq__c                 C   s   t |tƒr| j|jk S dS r.   r/   r0   r!   r!   r"   Ú__lt__f   r3   zAttrDef.__lt__c                 C   s   | j rt| j ƒS t| ƒS r+   )r   ÚhashÚidr,   r!   r!   r"   Ú__hash__l   s   
zAttrDef.__hash__c                 C   sJ   t | dƒr|dkrd| }ttƒrttd|| ƒ t|ƒ‚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"   r:   r   s   zAttrDef.__setattr__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r#   r*   r-   r2   r4   r7   r:   r!   r!   r!   r"   r   "   s    r   N)r@   Úosr   r   r   Úcore.exceptionsr   Ú	utils.logr   r   r	   r
   r   r   r9   r   r!   r!   r!   r"   Ú<module>   s     