
    f j                     r    d Z ddlmZ ddlmZmZ ddlmZmZmZ  G d de          Z	 G d de
          Zd	S )
z
RichText definition
    copy)
InlineFontText)StrictStringTypedc                   V    e Zd ZdZ ee          Z e            Zd Z	d Z
d Zd ZdS )	TextBlockzv Represents text string in a specific format

    This class is used as part of constructing a rich text strings.
    )expected_typec                 "    || _         || _        d S N)fonttext)selfr   r   s      kC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\openpyxl/cell/rich_text.py__init__zTextBlock.__init__   s    				    c                 B    | j         |j         k    o| j        |j        k    S r   )r   r   )r   others     r   __eq__zTextBlock.__eq__   s    yEJ&B49
+BBr   c                     | j         S )zJust retun the text)r   r   s    r   __str__zTextBlock.__str__   s
    yr   c                 t    | j         t                      k    r| j         pd}| j        j         d| j         d| S )Ndefaultz text=z, font=)r   r   	__class____name__r   )r   r   s     r   __repr__zTextBlock.__repr__#   sA    yJLL(6TYC).)IIII4IIIr   N)r   
__module____qualname____doc__r	   r   r   r   r   r   r   r   r    r   r   r   r      s          5z***D688D  
C C C  
J J J J Jr   r   c                        e Zd ZdZ fdZed             Zed             Zed             Z fdZ	 fdZ
d Z fd	Z fd
Z fdZd Zd Zd Z xZS )CellRichTexta  Represents a rich text string.

    Initialize with a list made of pure strings or :class:`TextBlock` elements
    Can index object to access or modify individual rich text elements
    it also supports the + and += operators between rich text strings
    There are no user methods for this class

    operations which modify the string will generally call an optimization pass afterwards,
    that merges text blocks with identical formats, consecutive pure text strings,
    and remove empty strings and empty text blocks
    c                 ^   t          |          dk    r]|d         }t          |t          t          f          rt                              |           n8t                              |           |g}nt                              |           t                                          |           d S )N   r   )	len
isinstancelisttupler%   _check_rich_text_check_elementsuperr   )r   argsr   s     r   r   zCellRichText.__init__<   s    t99> 	07D$u.. --d3333++D111v))$///r   c                 J    t          |d          rd S t          d|           )Nr   zIllegal CellRichText element )hasattr	TypeError)clsvalues     r   r-   zCellRichText._check_elementH   s0    5)$$ 	F???@@@r   c                 D    |D ]}t                               |           d S r   )r%   r-   )r3   	rich_textts      r   r,   zCellRichText._check_rich_textN   s2     	+ 	+A''****	+ 	+r   c                 p   t          j        |          }|j        r|j                            dd          fS g }|j        D ]k}d}|j        r|j                            dd          }|j        r)|                    t          |j        |                     V|                    |           l | |          S )Nx005F_ )r   	from_treer7   replacerrPrappendr   )r3   noder   sr=   r7   s         r   r;   zCellRichText.from_treeS   s    ~d##6 	3FNN8R0022 	 	AAs .CKK"--u 15!,,----s1vvr   c                    d }t          t                                }| D ]}t          |t                    r|sn|j        s#t          |          t          |          k    rAt          |t                    r||z  }^|j        |j        k    r|xj        |j        z  c_        |r|                    |           |}|r|                    |           t                      	                    t          d           |           | S r   )r%   r+   r)   strr   typer   r?   r.   __setitem__slice)r   last_tlr7   r   s       r   _optzCellRichText._opte   s   !! 	 	A!S!!  V F||tAww& a%% aKF[AF* KK16)KK !   FF 	HHVE$KK+++r   c                     t                               |           t                                          d t	          |          D                        |                                 S )Nc                 ,    g | ]}t          |          S r#   r   .0es     r   
<listcomp>z)CellRichText.__iadd__.<locals>.<listcomp>   s    555a$q''555r   )r%   r,   r.   __iadd__r*   rI   r   argr   s     r   rP   zCellRichText.__iadd__   sR    %%c***55499555666yy{{r   c                     t          d t          |           t          |          z   D                                                       S )Nc                 ,    g | ]}t          |          S r#   r   rL   s     r   rO   z(CellRichText.__add__.<locals>.<listcomp>   s    EEET!WWEEEr   )r%   r*   rI   )r   rR   s     r   __add__zCellRichText.__add__   s<    EEd4jj499.DEEEFFKKMMMr   c                     t                               |           t                                          ||           |                                  d S r   )r%   r-   r.   rE   rI   )r   indxvalr   s      r   rE   zCellRichText.__setitem__   sB    ##C(((D#&&&		r   c                 ~    t                               |           t                                          |           d S r   )r%   r-   r.   r?   rQ   s     r   r?   zCellRichText.append   s3    ##C(((sr   c                 ~    t                               |           t                                          |           d S r   )r%   r,   r.   extendrQ   s     r   r[   zCellRichText.extend   s3    %%c***sr   c                 f    d                     d                    d | D                                 S )NzCellRichText([{}])z, c              3   4   K   | ]}t          |          V  d S r   )reprrM   rA   s     r   	<genexpr>z(CellRichText.__repr__.<locals>.<genexpr>   s(      5L5L!d1gg5L5L5L5L5L5Lr   )formatjoinr   s    r   r   zCellRichText.__repr__   s1    #**4995L5Lt5L5L5L+M+MNNNr   c                 @    d                     d | D                       S )Nr:   c                 ,    g | ]}t          |          S r#   rC   r_   s     r   rO   z(CellRichText.__str__.<locals>.<listcomp>   s    ---1A---r   )rb   r   s    r   r   zCellRichText.__str__   s#    ww-----...r   c                     d | D             S )zv
        Returns a list of the strings contained.
        The main reason for this is to make editing easier.
        c                 ,    g | ]}t          |          S r#   re   r_   s     r   rO   z(CellRichText.as_list.<locals>.<listcomp>   s    %%%1A%%%r   r#   r   s    r   as_listzCellRichText.as_list   s    
 &%%%%%r   )r   r    r!   r"   r   classmethodr-   r,   r;   rI   rP   rU   rE   r?   r[   r   r   rh   __classcell__)r   s   @r   r%   r%   /   sU       
 

 
 
 
 
 A A [A
 + + [+   ["    4    N N N        
    
O O O/ / /& & & & & & &r   r%   N)r"   r   openpyxl.cell.textr   r   openpyxl.descriptorsr   r   r	   r   r*   r%   r#   r   r   <module>rm      s           / / / / / / / /         
J J J J J J J JDx& x& x& x& x&4 x& x& x& x& x&r   