o
    ðäj  ã                   @   s¾   d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ eg d¢ƒZd	 e¡Ze d
 e¡¡ZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )é    )ÚdefaultdictN)ÚSerialisable)ÚAliasÚStringÚIntegerÚBoolÚSequenceÚ
Descriptor)Úsafe_string)Ú	Tokenizer)ÚSHEETRANGE_RE)Ú
Print_AreaÚPrint_TitlesÚCriteriaÚ_FilterDatabaseÚExtractÚConsolidate_AreaÚSheet_Titleú|z^_xlnm\.(?P<name>{0})c                   @   s  e Zd ZdZeƒ Zedd�Zedd�Zedd�Zedd�Z	edd�Z
edd�Zedd�Zedd�Zedd�Zedd�Zedd�Zedd�Zedd�Zedd�Zeƒ ZedƒZ																ddd„Zedd	„ ƒZed
d„ ƒZedd„ ƒZedd„ ƒZdd„ Z dS )ÚDefinedNameÚdefinedNameT)Ú
allow_noneÚ	attr_textNc                 C   sd   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _|| _|| _d S ©N)ÚnameÚcommentÚ
customMenuÚdescriptionÚhelpÚ	statusBarÚlocalSheetIdÚhiddenÚfunctionÚvbProcedureÚxlmÚfunctionGroupIdÚshortcutKeyÚpublishToServerÚworkbookParameterr   )Úselfr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r   © r*   úb/var/www/ticemtrilhas/avaliacao_env/lib/python3.10/site-packages/openpyxl/workbook/defined_name.pyÚ__init__2   s    
zDefinedName.__init__c                 C   s.   t d| j ƒ}|jd }|jdkr|jS |jS )Nú=r   ÚOPERAND)r   ÚvalueÚitemsÚtypeÚsubtype)r)   ÚtokÚparsedr*   r*   r+   r1   V   s
   

zDefinedName.typec                 c   sh   � | j dkr0td| j ƒ}|jD ]!}|jdkr/t |j¡}| d¡p&| d¡}|| d¡fV  qd S d S )NÚRANGEr-   Ú	notquotedÚquotedÚcells)r1   r   r/   r0   r2   r   ÚmatchÚgroup)r)   r3   ÚpartÚmÚ	sheetnamer*   r*   r+   Údestinations_   s   €


€úzDefinedName.destinationsc                 C   s   t  | j¡}|r| d¡S d S )Nr   )ÚRESERVED_REGEXr9   r   r:   )r)   r<   r*   r*   r+   Úis_reservedj   s   
ÿzDefinedName.is_reservedc                 C   s   t  d¡ | j¡d uS )Nz
^\[\d+\].*)ÚreÚcompiler9   r/   ©r)   r*   r*   r+   Úis_externalq   s   zDefinedName.is_externalc                 c   sL   � | j D ]}|dkrqt| |ƒ}|d ur#|tv rd| }|t|ƒfV  qd S )Nr   z_xlnm.)Ú	__attrs__ÚgetattrÚRESERVEDr
   )r)   ÚkeyÚvr*   r*   r+   Ú__iter__v   s   €

€ùzDefinedName.__iter__)NNNNNNNNNNNNNNNN)!Ú__name__Ú
__module__Ú__qualname__Útagnamer   r   r   r   r   r   r   r   r    r   r!   r"   r#   r$   r%   r&   r'   r(   r	   r   r   r/   r,   Úpropertyr1   r>   r@   rD   rJ   r*   r*   r*   r+   r      sZ    














ð$




r   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚDefinedNameDictzv
    Utility class for storing defined names.
    Allows access by name and separation of global and scoped names
    c                    s6   t |tƒs	tdƒ‚|j|krtdƒ‚tƒ  ||¡ d S )Nz*Value must be a an instance of DefinedNamez Key must be the same as the name)Ú
isinstancer   Ú	TypeErrorr   Ú
ValueErrorÚsuperÚ__setitem__)r)   rH   r/   ©Ú	__class__r*   r+   rU   ˆ   s
   

zDefinedNameDict.__setitem__c                 C   s   || |j < dS )zI
        Add names without worrying about key and name matching.
        N)r   )r)   r/   r*   r*   r+   Úadd�   s   zDefinedNameDict.add)rK   rL   rM   Ú__doc__rU   rX   Ú__classcell__r*   r*   rV   r+   rP   �   s    rP   c                   @   s<   e Zd ZdZeed�Zddd„Zdd„ Zdd	„ Z	d
d„ Z
dS )ÚDefinedNameListÚdefinedNames)Úexpected_typer*   c                 C   s
   || _ d S r   )r   )r)   r   r*   r*   r+   r,   ž   ó   
zDefinedNameList.__init__c                 C   sV   t tƒ}| jD ]!}|jdu r|jdv rq||d |j< qt|jƒ}||| |j< q|S )z@
        Break names down into sheet locals and globals
        N)z_xlnm.Print_Titlesz_xlnm.Print_Areaz_xlnm._FilterDatabaseÚglobal)r   rP   r   r    r   Úint)r)   ÚnamesÚdefnÚsheetr*   r*   r+   Úby_sheet¢   s   



zDefinedNameList.by_sheetc                 C   s.   | j D ]}|j|jkr|j|jkr dS qdS )zc
        Check for whether DefinedName with the same name and scope already
        exists
        TN)r   r   r    )r)   rb   Údr*   r*   r+   Ú
_duplicate²   s
   
€þzDefinedNameList._duplicatec                 C   s
   t | jƒS r   )Úlenr   rC   r*   r*   r+   Ú__len__¼   r^   zDefinedNameList.__len__N)r*   )rK   rL   rM   rN   r   r   r   r,   rd   rf   rh   r*   r*   r*   r+   r[   —   s    


r[   )Úcollectionsr   rA   Ú!openpyxl.descriptors.serialisabler   Úopenpyxl.descriptorsr   r   r   r   r   r	   Úopenpyxl.compatr
   Úopenpyxl.formular   Úopenpyxl.utils.cellr   Ú	frozensetrG   ÚjoinÚ_namesrB   Úformatr?   r   ÚdictrP   r[   r*   r*   r*   r+   Ú<module>   s    
f