
    ddb                         d dl mZ d dlmZ d dlmZ ddlmZmZm	Z	 ddl
mZ  G d de          Z G d	 d
e          Z G d de          Z G d de          Z G d de          ZdS )    )safe_string)Element)IndexedList   )
DescriptorAlias_convert)
namespacedc                   P     e Zd ZdZ ed          ZeefZdZ	dZ
 fdZddZ xZS )Sequencez[
    A sequence (list or tuple) that may only contain objects of the declared
    type
    Nr   Fc                      t          | j                  st          d           fd|D             } j        rt	          |          }t          t                                         ||           d S )NValue must be a sequencec                 :    g | ]}t          j        |          S  )r	   expected_type).0valueselfs     =lib/python3.11/site-packages/openpyxl/descriptors/sequence.py
<listcomp>z$Sequence.__set__.<locals>.<listcomp>   s&    DDDux*E22DDD    )
isinstance	seq_types	TypeErroruniquer   superr   __set__)r   instanceseq	__class__s   `  r   r   zSequence.__set__   s}    #t~.. 	86777DDDDDDD; 	#c""Ch%%h44444r   c              #      K   t          || j                  D ]d\  }}t          |d          r|                    ||          }n4t	          |||          }t          |          }t          |          |_        |V  edS )V
        Convert the sequence represented by the descriptor to an XML element
        to_treeN)	enumerateidx_basehasattrr#   r
   r   r   text)r   tagnameobj	namespaceidxvels          r   r#   zSequence.to_tree!   s        T]33 	 	FCq)$$ )YYw,,$S'9==W%%%a..HHHH	 	r   N)__name__
__module____qualname____doc__typer   listtupler   r%   r   r   r#   __classcell__)r    s   @r   r   r      sx         
 DJJMuIHF5 5 5 5 5       r   r   c                   $    e Zd ZdZdZddZd ZdS )ValueSequencezq
    A sequence of primitive types that are stored as a single attribute.
    "val" is the default attribute
    valNc              #      K   t          | ||          }|D ](}t          || j        t          |          i          V  )d S r.   )r
   r   	attributer   )r   r(   r)   r*   r,   s        r   r#   zValueSequence.to_tree8   sZ      T7I66 	D 	DA'DN;q>>#BCCCCCC	D 	Dr   c                 6    |                     | j                  S r.   )getr;   r   nodes     r   	from_treezValueSequence.from_tree>   s    xx'''r   r.   )r/   r0   r1   r2   r;   r#   r@   r   r   r   r8   r8   /   sL         
 ID D D D( ( ( ( (r   r8   c                   $    e Zd ZdZdZddZd ZdS )NestedSequencez1
    Wrap a sequence in an containing object
    FNc                    t          | ||          }t          |          }| j        r0|                    dt	          t          |                               |D ])}|                    |                                           *|S )Ncount)r
   r   rD   setstrlenappendr#   )r   r(   r)   r*   	containerr,   s         r   r#   zNestedSequence.to_treeJ   s~    T7I66G$$	: 	2MM'3s3xx==111 	* 	*AQYY[[))))r   c                        fd|D             S )Nc                 D    g | ]}j                             |          S r   )r   r@   )r   r-   r   s     r   r   z,NestedSequence.from_tree.<locals>.<listcomp>U   s*    @@@R",,R00@@@r   r   r>   s   ` r   r@   zNestedSequence.from_treeT   s    @@@@4@@@@r   r.   )r/   r0   r1   r2   rD   r#   r@   r   r   r   rB   rB   C   sM          E   A A A A Ar   rB   c                        e Zd ZdZd ZddZdS )MultiSequencez;
    Sequences can contain objects with different tags
    c                     t          |t          t          f          st          d          t          |          }t	          j        | ||           d S )Nr   )r   r5   r4   
ValueErrorr   r   )r   r   r   s      r   r   zMultiSequence.__set__]   sM    #t}-- 	978883ii43/////r   Nc              #   H   K   |D ]}|                     |          }|V  dS )r"   )r*   N)r#   )r   r(   r)   r*   r,   r-   s         r   r#   zMultiSequence.to_treed   s?        	 	AY//BHHHH	 	r   r.   )r/   r0   r1   r2   r   r#   r   r   r   rM   rM   X   sA         0 0 0     r   rM   c                   $    e Zd ZdZd Zd Zd ZdS )MultiSequencePartz
    Allow a multisequence to be built up from parts

    Excluded from the instance __elements__ or __attrs__ as is effectively an Alias
    c                 "    || _         || _        d S r.   )r   store)r   r   rT   s      r   __init__zMultiSequencePart.__init__t   s    *


r   c                 z    t          | j        |          }|j        | j                                     |           d S r.   )r	   r   __dict__rT   rH   )r   r   r   s      r   r   zMultiSequencePart.__set__y   s8    +U33$*%,,U33333r   c                     | S r.   r   )r   r   clss      r   __get__zMultiSequencePart.__get__~   s    r   N)r/   r0   r1   r2   rU   r   rZ   r   r   r   rR   rR   m   sK           
4 4 4
    r   rR   N)openpyxl.compatr   openpyxl.xml.functionsr   openpyxl.utils.indexed_listr   baser   r   r	   r*   r
   r   r8   rB   rM   rR   r   r   r   <module>r_      sR   ( ' ' ' ' ' * * * * * * 3 3 3 3 3 3 - - - - - - - - - - ! ! ! ! ! !! ! ! ! !z ! ! !H( ( ( ( (H ( ( ((A A A A AX A A A*    H   *         r   