o
    g
                     @   sj   d dl mZ d dlmZmZmZmZ d dlmZ ddl	m
Z
 d dlmZ G dd deZG d	d
 d
ZdS )    )OrderedDict)BoolSequenceAliasConvertible)Serialisable   )Rule)MultiCellRangec                   @   sh   e Zd ZdZeedZedZe	ddZ
eedZedZdd	d
Zdd Zdd Zdd Zdd ZdS )ConditionalFormattingconditionalFormatting)expected_typesqrefT)
allow_nonecfRule Nc                 C   s   || _ || _|| _d S N)r   pivotr   )selfr   r   r   extLstr   r   X/var/www/html/api-tag/env/lib/python3.10/site-packages/openpyxl/formatting/formatting.py__init__   s   
zConditionalFormatting.__init__c                 C   s   t || jsdS | j|jkS )NF)
isinstance	__class__r   )r   otherr   r   r   __eq__"   s   zConditionalFormatting.__eq__c                 C   
   t | jS r   )hashr   r   r   r   r   __hash__(      
zConditionalFormatting.__hash__c                 C   s   dj | jj| jdS )Nz<{cls} {cells}>)clscells)formatr   __name__r   r   r   r   r   __repr__,   s   zConditionalFormatting.__repr__c                 C   s
   || j v S )zL
        Check whether a certain cell is affected by the formatting
        r   )r   coordr   r   r   __contains__0   s   
z"ConditionalFormatting.__contains__)r   Nr   N)r$   
__module____qualname__tagnamer   r
   r   r   r"   r   r   r   r	   r   rulesr   r   r   r%   r(   r   r   r   r   r      s    



r   c                   @   sP   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdS )ConditionalFormattingListzConditional formatting rules.c                 C   s   t  | _d| _d S )Nr   )r   	_cf_rulesmax_priorityr   r   r   r   r   ;   s   
z"ConditionalFormattingList.__init__c                 C   s`   |}t |trt|}t |tstd|}|  jd7  _|js$| j|_| j|g 	| dS )zyAdd a rule such as ColorScaleRule, FormulaRule or CellIsRule

         The priority will be added automatically.
        z<Only instances of openpyxl.formatting.rule.Rule may be addedr   N)
r   strr   r	   
ValueErrorr/   priorityr.   
setdefaultappend)r   range_stringr   cfruler   r   r   add@   s   

zConditionalFormattingList.addc                 C   r   r   )boolr.   r   r   r   r   __bool__R   r    z"ConditionalFormattingList.__bool__c                 C   r   r   )lenr.   r   r   r   r   __len__V   r    z!ConditionalFormattingList.__len__c                 c   s&    | j  D ]
\}}||_|V  qd S r   )r.   itemsr,   )r   r6   r,   r   r   r   __iter__Z   s
   z"ConditionalFormattingList.__iter__c                 C   s   t |tr
t|d}| j| S )z0
        Get the rules for a cell range
        r&   )r   r0   r   r.   r   keyr   r   r   __getitem__`   s   


z%ConditionalFormattingList.__getitem__c                 C   s   t |d}| j|= d S )Nr&   )r   r.   r?   r   r   r   __delitem__i   s   
z%ConditionalFormattingList.__delitem__c                 C   s   |  || dS )z-
        Add a rule for a cell range
        N)r8   )r   r@   r7   r   r   r   __setitem__n   s   z%ConditionalFormattingList.__setitem__N)r$   r)   r*   __doc__r   r8   r:   r<   r>   rA   rB   rC   r   r   r   r   r-   7   s    	r-   N)collectionsr   openpyxl.descriptorsr   r   r   r   !openpyxl.descriptors.serialisabler   r7   r	   openpyxl.worksheet.cell_ranger
   r   r-   r   r   r   r   <module>   s   &