
    Mwg                     "   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	j)                  e      Z ej,                  d
j/                  e            Z G d de      Z G d de      Z G d de      Zy)    )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                      e Zd ZdZ e       Z ed      Z ed      Z ed      Z ed      Z	 ed      Z
 ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z e       Z ed      Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZed        Zed        Zed	        Zed
        Zd Z y)DefinedNamedefinedNameT)
allow_none	attr_textNc                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        || _        y 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   s                    U/var/www/horilla/myenv/lib/python3.12/site-packages/openpyxl/workbook/defined_name.py__init__zDefinedName.__init__2   s{    $ 	$&	"( &.&.!2"    c                     t        d| j                  z         }|j                  d   }|j                  dk(  r|j                  S |j                  S )N=r   OPERAND)r   valueitemstypesubtype)r,   tokparseds      r-   r5   zDefinedName.typeV   sB    djj()1;;)#>>!{{r/   c              #   N  K   | j                   dk(  rt        d| j                  z         }|j                  D ]j  }|j                  dk(  st        j                  |j                        }|j                  d      xs |j                  d      }||j                  d      f l y y w)NRANGEr1   	notquotedquotedcells)r5   r   r3   r4   r6   r   matchgroup)r,   r7   partm	sheetnames        r-   destinationszDefinedName.destinations_   s     99C$**,-C		 6<<7*%++DJJ7A ! 4 I8II#QWWW%555	6  s   AB%	AB%c                 h    t         j                  | j                        }|r|j                  d      S y )Nr   )RESERVED_REGEXr>   r   r?   )r,   rA   s     r-   is_reservedzDefinedName.is_reservedj   s,      +776?" r/   c                 b    t        j                  d      j                  | j                        d uS )Nz
^\[\d+\].*)recompiler>   r3   r,   s    r-   is_externalzDefinedName.is_externalq   s%    zz-(..tzz:$FFr/   c              #      K   | j                   D ]3  }|dk(  r	t        | |      }||t        v rd|z   }|t        |      f 5 y w)Nr   z_xlnm.)	__attrs__getattrRESERVEDr   )r,   keyvs      r-   __iter__zDefinedName.__iter__v   sT     >> 	*Ck!c"A}= 1A;q>))	*s
   $AA)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   r3   r.   propertyr5   rC   rF   rK   rR    r/   r-   r   r      s;   G8D%G4(JD)KT"D$'Id+LT"Ft$H$'K
$
C.OD)Kd+O-I+E  !"!!%!!%#'!!#H   6 6 # # G G*r/   r   c                   (     e Zd ZdZ fdZd Z xZS )DefinedNameDictzv
    Utility class for storing defined names.
    Allows access by name and separation of global and scoped names
    c                     t        |t              st        d      |j                  |k7  rt	        d      t
        |   ||       y )Nz*Value must be a an instance of DefinedNamez Key must be the same as the name)
isinstancer   	TypeErrorr   
ValueErrorsuper__setitem__)r,   rP   r3   	__class__s      r-   r`   zDefinedNameDict.__setitem__   s@    %-HIIZZ3?@@C'r/   c                 "    || |j                   <   y)zI
        Add names without worrying about key and name matching.
        N)r   )r,   r3   s     r-   addzDefinedNameDict.add   s     !UZZr/   )rS   rT   rU   __doc__r`   rc   __classcell__)ra   s   @r-   rZ   rZ      s    
(!r/   rZ   c                   <    e Zd ZdZ ee      ZddZd Zd Z	d Z
y)	DefinedNameListdefinedNames)expected_typec                     || _         y r   )r   )r,   r   s     r-   r.   zDefinedNameList.__init__   s
    &r/   c                     t        t              }| j                  D ]W  }|j                  "|j                  dv r||d   |j                  <   1t        |j                        }|||   |j                  <   Y |S )z@
        Break names down into sheet locals and globals
        )z_xlnm.Print_Titlesz_xlnm.Print_Areaz_xlnm._FilterDatabaseglobal)r   rZ   r   r#   r   int)r,   namesdefnsheets       r-   by_sheetzDefinedNameList.by_sheet   sz     O,$$ 	/D  (99 cc-1h		*D--.*.eTYY'	/ r/   c                     | j                   D ]7  }|j                  |j                  k(  s|j                  |j                  k(  s7 y y)zc
        Check for whether DefinedName with the same name and scope already
        exists
        TN)r   r   r#   )r,   ro   ds      r-   
_duplicatezDefinedNameList._duplicate   s=    
 !! 	Avv"q~~9J9J'J	r/   c                 ,    t        | j                        S r   )lenr   rJ   s    r-   __len__zDefinedNameList.__len__   s    4##$$r/   N)rX   )rS   rT   rU   rV   r	   r   r   r.   rq   rt   rw   rX   r/   r-   rg   rg      s%    G5K' %r/   rg   )collectionsr   rH   !openpyxl.descriptors.serialisabler   openpyxl.descriptorsr   r   r   r   r	   r
   openpyxl.compatr   openpyxl.formular   openpyxl.utils.cellr   	frozensetrO   join_namesrI   formatrE   r   dictrZ   rg   rX   r/   r-   <module>r      s    $ 	 :  ( & - % & 
(	4;;FCDc*, c*L!d !,&%l &%r/   