+
    Ĝi:                         ^ RI H t  ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHt  ! R R	]	4      t ! R
 R]4      tR# )    )copy)
attrgetter)Strict)MinMax)UniqueSequence)Serialisable)range_boundariesrange_to_tupleget_column_letterquote_sheetnamec                     a  ] tR t^t o Rt]! ^R]R7      t]! ^R]R7      t]! ^R]R7      t	]! ^R]R7      t
R&R lt]R 4       t]R 4       t]R	 4       t]R
 4       t]R 4       tR tR tR tR tR tR'R ltR tR tR t]tR tR tR t]tR t R t!R t"R t#]#t$R t%]%t&R t'R(R lt(R(R lt)]R  4       t*]R! 4       t+]R" 4       t,]R# 4       t-]R$ 4       t.R%t/V t0R# ))	CellRangea  
Represents a range in a sheet: title and coordinates.

This object is used to perform operations on ranges, like:

- shift, expand or shrink
- union/intersection with another sheet range,

We can check whether a range is:

- equal or not equal to another,
- disjoint of another,
- contained in another.

We can get:

- the size of a range.
- the range bounds (vertices)
- the coordinates,
- the string representation,

ifG  )minmaxexpected_typei   Nc                $   Ve(   RV9   d   \        V4      w  pw  r#rEM\        V4      w  r#rEW n        W0n        W@n        WPn        W`n        W$8  d   Rp\        VP                  W$R7      4      hW58  d   Rp\        VP                  W5R7      4      hR # )N!z({max_col} must be greater than {min_col})min_colmax_colz({max_row} must be greater than {min_row})min_rowmax_row)	r
   r	   r   r   r   r   title
ValueErrorformat)selfrange_stringr   r   r   r   r   fmts   &&&&&&& f/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/openpyxl/worksheet/cell_range.py__init__CellRange.__init__0   s    #l">L\>Z;;'75El5S2'
<CSZZZIJJ<CSZZZIJJ     c                ^    V P                   V P                  V P                  V P                  3# )z"
Vertices of the range as a tuple
r   r   r   r   r   s   &r   boundsCellRange.boundsF   s#    
 ||T\\4<<EEr!   c                   RpV P                   V P                  8X  d   V P                  V P                  8X  d   RpVP	                  \        V P                   4      V P                  \        V P                  4      V P                  R7      # )z)
Excel-style representation of the range
z%{min_col}{min_row}:{max_col}{max_row}z{min_col}{min_row}r#   )r   r   r   r   r   r   r   r   s   & r   coordCellRange.coordN   sj    
 6LLDLL(,&Czz%dll3LL%dll3LL	  
 	
r!   c              #     "   \        V P                  V P                  ^,           4       F=  p\        V P                  V P                  ^,           4       Uu. uF  q!V3NK  	  upx  K?  	  R# u upi 5i)z!
Return cell coordinates as rows
N)ranger   r   r   r   )r   rowcols   &  r   rowsCellRange.rows_   S     
 t||A~6C).t||T\\!^)LM)L#:)LMM 7M   AA2A-"A2c              #     "   \        V P                  V P                  ^,           4       F=  p\        V P                  V P                  ^,           4       Uu. uF  q"V3NK  	  upx  K?  	  R# u upi 5i)z$
Return cell coordinates as columns
N)r,   r   r   r   r   )r   r.   r-   s   &  r   colsCellRange.colsh   r1   r2   c                    ^ RI Hp V! \        V P                  V P                  ^,           4      \        V P
                  V P                  ^,           4      4      # )r   )product)	itertoolsr7   r,   r   r   r   r   )r   r7   s   & r   cellsCellRange.cellsq   s=    %uT\\4<<>:E$,,PTP\P\]^P^<_``r!   c                    \        V\        4      '       g   \        \        \	        V4      4      4      hVP
                  '       d)   V P
                  VP
                  8w  d   \        R4      hR# R# )z
Check whether comparisons between ranges are possible.
Cannot compare ranges from different worksheets
Skip if the range passed in has no title.
z1Cannot work with ranges from different worksheetsN)
isinstancer   	TypeErrorreprtyper   r   r   others   &&r   _check_titleCellRange._check_titlew   sP     %++De-..;;;4::4PQQ 5;r!   c                    R pV P                   '       d   RpVP                  V P                  P                  V P                   V P                  R7      # )z<{cls} {coord}>z<{cls} {title!r}!{coord}>)clsr   r)   )r   r   	__class____name__r)   r(   s   & r   __repr__CellRange.__repr__   s<     :::.Czzdnn55TZZtzzzZZr!   c                p    \        V P                  V P                  V P                  V P                  34      # N)hashr   r   r   r   r$   s   &r   __hash__CellRange.__hash__   s&    T\\4<<t||LMMr!   c                    R pV P                   pV'       d   Rp\        V4      pVP                  W P                  R7      # )z{coord}z{title}!{coord})r   r)   )r   r   r   r)   )r   r   r   s   &  r   __str__CellRange.__str__   s7    

$C#E*EzzZZz88r!   c                    V P                  V P                  V P                  V P                  V P                  V P
                  R 7      # )r   r   r   r   r   )rF   r   r   r   r   r   r$   s   &r   __copy__CellRange.__copy__   s8    ~~dllDLL&*llDLL$(JJ  0 	0r!   c                b   V P                   V,           ^ 8:  g   V P                  V,           ^ 8:  d   \        RP                  W4      4      hV ;P                   V,          un         V ;P                  V,          un        V ;P                  V,          un        V ;P
                  V,          un        R# )aC  
Shift the focus of the range according to the shift values (*col_shift*, *row_shift*).

:type col_shift: int
:param col_shift: number of columns to be moved by, can be negative
:type row_shift: int
:param row_shift: number of rows to be moved by, can be negative
:raise: :class:`ValueError` if any row or column index < 1
z1Invalid shift value: col_shift={0}, row_shift={1}N)r   r   r   r   r   r   )r   	col_shift	row_shifts   &&&r   shiftCellRange.shift   sv     LL9$)||i'1,PWWXamnn	!	!	!	!r!   c                B    V P                  V4       TP                  T P                  8g  ;'       g\    T P                  TP                  8g  ;'       g;    TP                  T P                  8g  ;'       g    T P
                  TP
                  8g  #   \         d     R# i ; i)z
Test whether the ranges are not equal.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* != *other*.
T)rB   r   r   r   r   r   r@   s   &&r   __ne__CellRange.__ne__   s    	e$
 MMT\\) - -||u}},- -}},- - ||u}},		
  		s   B BBc                .    V P                  V4      '       * # )z
Test whether the ranges are equal.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* == *other*.
)r\   r@   s   &&r   __eq__CellRange.__eq__   s     ;;u%%%r!   c                F    V P                  V4       VP                  V 4      # )z
Test whether every cell in this range is also in *other*.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* <= *other*.
rB   _CellRange__supersetr@   s   &&r   issubsetCellRange.issubset   s#     	% %%r!   c                V    V P                  V4      ;'       d    V P                  V4      # )z
Test whether *other* contains every cell of this range, and more.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* < *other*.
)__le__r\   r@   s   &&r   __lt__CellRange.__lt__   $     {{5!88dkk%&88r!   c                B   V P                   VP                   u;8*  ;'       d(    VP                  u;8*  ;'       d    V P                  8*  Mu ;'       dM    V P                  VP                  u;8*  ;'       d(    VP                  u;8*  ;'       d    V P                  8*  # u # rK   )r   r   r   r   r@   s   &&r   
__supersetCellRange.__superset   sn    \\U]]KKemmKKt||K M M\\U]]KKemmKKt||K	
 L	
r!   c                F    V P                  V4       V P                  V4      # )z
Test whether every cell in *other* is in this range.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* >= *other* (or *other* in *range*).
rb   r@   s   &&r   
issupersetCellRange.issuperset   s!     	% u%%r!   c                F    V P                  V4      pV P                  V4      # )z?
Check whether the range contains a particular cell coordinate
)rF   rc   r   r)   crs   && r   __contains__CellRange.__contains__  s!     ^^E"r""r!   c                V    V P                  V4      ;'       d    V P                  V4      # )z
Test whether this range contains every cell in *other*, and more.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range
:return: ``True`` if *range* > *other*.
)__ge__r\   r@   s   &&r   __gt__CellRange.__gt__  rj   r!   c                   V P                  V4       V P                  VP                  8  d   YrV P                  VP                  8  ;'       g;    V P                  VP
                  8  ;'       g    VP                  V P
                  8  # )a&  
Return ``True`` if this range has no cell in common with *other*.
Ranges are disjoint if and only if their intersection is the empty range.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range.
:return: ``True`` if the range has no cells in common with other.
)rB   r%   r   r   r   r   r@   s   &&r   
isdisjointCellRange.isdisjoint  sr     	%  ;;%%u}}, 0 0<<%--/0 0==4<</	1r!   c                   V P                  V4      '       d   \        RP                  W4      4      h\        V P                  VP                  4      p\        V P                  VP                  4      p\        V P                  VP                  4      p\        V P                  VP                  4      p\        WBVVR7      # )a  
Return a new range with cells common to this range and *other*

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range.
:return: the intersecting sheet range.
:raise: :class:`ValueError` if the *other* range doesn't intersect
    with this range.
zRange {0} doesn't intersect {0}r#   )
r{   r   r   r   r   r   r   r   r   r   r   rA   r   r   r   r   s   &&    r   intersectionCellRange.intersection*  s     ??5!!>EEdRSSdllEMM2dllEMM2dllEMM2dllEMM27!(* 	*r!   c                T   V P                  V4       \        V P                  VP                  4      p\        V P                  VP                  4      p\        V P
                  VP
                  4      p\        V P                  VP                  4      p\        WBVW0P                  R7      # )aW  
Return the minimal superset of this range and *other*. This new range
will contain all cells from this range, *other*, and any additional
cells required to form a rectangular ``CellRange``.

:type other: openpyxl.worksheet.cell_range.CellRange
:param other: Other sheet range.
:return: a ``CellRange`` that is a superset of this and *other*.
rS   )	rB   r   r   r   r   r   r   r   r   r~   s   &&    r   unionCellRange.unionB  sz     	% dllEMM2dllEMM2dllEMM2dllEMM27!(

< 	<r!   c              #  f   "   V P                    F  pVR8X  d   K  \        W4      pW3x  K  	  R# 5i)z3
For use as a dictionary elsewhere in the library.
r   N)	__attrs__getattr)r   xvs   &  r   __iter__CellRange.__iter__X  s0      AG| A$J	  s   /1c                    V ;P                   V,          un         V ;P                  V,          un        V ;P                  V,          un        V ;P                  V,          un        R# )aV  
Expand the range by the dimensions provided.

:type right: int
:param right: expand range to the right by this number of cells
:type down: int
:param down: expand range down by this number of cells
:type left: int
:param left: expand range to the left by this number of cells
:type up: int
:param up: expand range up by this number of cells
Nr#   )r   rightdownleftups   &&&&&r   expandCellRange.expandc  s<     	r!   c                    V ;P                   V,          un         V ;P                  V,          un        V ;P                  V,          un        V ;P                  V,          un        R# )ao  
Shrink the range by the dimensions provided.

:type right: int
:param right: shrink range from the right by this number of cells
:type down: int
:param down: shrink range from the top by this number of cells
:type left: int
:param left: shrink range from the left by this number of cells
:type up: int
:param up: shrink range from the bottom by this number of cells
Nr#   )r   r   bottomr   tops   &&&&&r   shrinkCellRange.shrinkv  s<     	r!   c                    V P                   ^,           V P                  ,
          pV P                  ^,           V P                  ,
          pRVRV/# )zBReturn the size of the range as a dictionary of rows and columns. columnsr/   )r   r   r   r   )r   r4   r/   s   &  r   sizeCellRange.size  sA     ||a$,,.||a$,,.$t,,r!   c                    \        V P                  V P                  ^,           4       Uu. uF  qP                  V3NK  	  up# u upi )z=A list of cell coordinates that comprise the top of the range)r,   r   r   r   r   r.   s   & r   r   CellRange.top  9     05T\\4<<PQ>/RS/Rs#/RSSS   Ac                    \        V P                  V P                  ^,           4       Uu. uF  qP                  V3NK  	  up# u upi )z@A list of cell coordinates that comprise the bottom of the range)r,   r   r   r   r   s   & r   r   CellRange.bottom  r   r   c                    \        V P                  V P                  ^,           4       Uu. uF  qV P                  3NK  	  up# u upi )zCA list of cell coordinates that comprise the left-side of the range)r,   r   r   r   r   r-   s   & r   r   CellRange.left  9     05T\\4<<PQ>/RS/Rdll#/RSSSr   c                    \        V P                  V P                  ^,           4       Uu. uF  qV P                  3NK  	  up# u upi )zDA list of cell coordinates that comprise the right-side of the range)r,   r   r   r   r   s   & r   r   CellRange.right  r   r   )r   r   r   r   r   )NNNNNN)r   r   )r   r   r   r   )1rG   
__module____qualname____firstlineno____doc__r   intr   r   r   r   r   propertyr%   r)   r/   r4   r9   rB   rH   rM   rP   rT   rY   r\   r_   rd   rg   rh   rc   ro   rw   rt   rx   r{   r   __and__r   __or__r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s    . S9Gs;GS9Gs;GK, F F 
 
  N N N N a a

R[N90"(
*&
& F9

& F#91(** G<& F&& - - T T
 T T
 T T
 T Tr!   r   c                      a  ] tR tRt o ]! ]R7      t]! 4       3R ltR t	R t
R tR tR tR	 tR
 tR tR tR tR tR tR tRtV tR# )MultiCellRangei  )r   c                    \        V\        4      '       d)   VP                  4        Uu. uF  p\        V4      NK  	  pp\	        V4      V n        R # u upi rK   )r<   strsplitr   setranges)r   r   rs   && r   r   MultiCellRange.__init__  s=    fc"",2LLN;NqilNF;&k <s   Ac                    \        V\        4      '       d   \        V4      pV P                   F  pW8:  g   K   R # 	  R# )TF)r<   r   r   r   )r   r)   r   s   && r   rt   MultiCellRange.__contains__  s4    eS!!e$EAz  r!   c                    R P                  V P                  4        Uu. uF  p\        V4      NK  	  up4      pRV P                  P                   RV R2# u upi ) <z [z]>)joinsortedr   rF   rG   r   r   r   s   &  r   rH   MultiCellRange.__repr__  sN    4;;=9=a3q6=9:4>>**+2fXR88 :s   Ac                    R P                  V P                  4        Uu. uF  p\        V4      NK  	  up4      pV# u upi )r   )r   r   r   r   s   &  r   rP   MultiCellRange.__str__  s3    DKKM:MqCFM:; ;s   ;c                *    \        \        V 4      4      # rK   )rL   r   r$   s   &r   rM   MultiCellRange.__hash__  s    CIr!   c           	     H    \        V P                  \        RRRR4      R7      # )z
Return a sorted list of items
r   r   r   r   )key)r   r   r   r$   s   &r   r   MultiCellRange.sorted  s!     dkkz)Y	S\']^^r!   c                    Tp\        V\        4      '       d   \        V4      pM!\        V\        4      '       g   \        R4      hW 9  d   V P                  P                  V4       R# R# )z$
Add a cell coordinate or CellRange
zYou can only add CellRangesN)r<   r   r   r   r   addrr   s   && r   r   MultiCellRange.add  sS     eS!!5!BE9--:;;>KKOOB r!   c                (    V P                  V4       V # rK   )r   r   r)   s   &&r   __iadd__MultiCellRange.__iadd__  s    r!   c                    \        V\        4      '       d   V P                  V4      pV P                  VP                  8H  # rK   )r<   r   rF   r   r@   s   &&r   r_   MultiCellRange.__eq__  s0    uc""NN5)E{{ell**r!   c                    W8X  * # rK    r@   s   &&r   r\   MultiCellRange.__ne__  s      r!   c                ,    \        V P                  4      # rK   )boolr   r$   s   &r   __bool__MultiCellRange.__bool__  s    DKK  r!   c                ~    \        V\        4      '       g   \        V4      pV P                  P                  V4       R # rK   )r<   r   r   remover   s   &&r   r   MultiCellRange.remove  s+    %++e$E5!r!   c              #  <   "   V P                    F  pVx  K	  	  R # 5irK   r   )r   rs   s   & r   r   MultiCellRange.__iter__  s     ++BH s   c                j    V P                    Uu0 uF  p\        V4      kK  	  pp\        V4      # u upi rK   )r   r   r   r   s   &  r   rT   MultiCellRange.__copy__  s.    #';;/;a$q';/f%% 0s   0r   N)rG   r   r   r   r   r   r   r   r   rt   rH   rP   rM   r   r   r   r_   r\   r   r   r   rT   r   r   r   s   @r   r   r     sd      )4F "e "9

_
 
+!!"
& &r!   r   N)r   operatorr   openpyxl.descriptorsr   r   openpyxl.descriptors.sequencer   !openpyxl.descriptors.serialisabler   openpyxl.utilsr	   r
   r   r   r   r   r   r!   r   <module>r      sB      ' ' 8 : TT TTnW&V W&r!   