hyb
2025-12-23 7e5db3a16b423ec4a43459805e277979bcac7db5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Ë
dñúhýãó^—dZddlZddlmZmZddlmZmZmZGd„de    «Z
Gd„d    «Z y)
a!
This module contains code to translate formulae across cells in a worksheet.
 
The idea is that if A1 has formula "=B1+C1", then translating it to cell A2
results in formula "=B2+C2". The algorithm relies on the formula tokenizer
to identify the parts of the formula that need to change.
 
éNé)Ú    TokenizerÚToken)Úcoordinate_to_tupleÚcolumn_index_from_stringÚget_column_lettercó—eZdZdZy)ÚTranslatorErrora
    Raised when a formula can't be translated across cells.
 
    This error arises when a formula's references would be translated outside
    the worksheet's bounds on the top or left. Excel represents these
    situations with a #REF! literal error. E.g., if the formula at B2 is
    '=A1', attempting to translate the formula to B1 raises TranslatorError,
    since there's no cell above A1. Similarly, translating the same formula
    from B2 to A2 raises TranslatorError, since there's no cell to the left of
    A1.
 
    N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__©óúMH:\Change_password\venv_build\Lib\site-packages\openpyxl/formula/translate.pyr
r
s„ò rr
cóЗeZdZdZd„Zd„Zejd«Zejd«Z    ejd«Z
e d„«Z e d„«Z e d    „«Zed
„«Zd d „Zy )Ú
Translatora5
    Modifies a formula so that it can be translated from one cell to another.
 
    `formula`: The str string to translate. Must include the leading '='
               character.
    `origin`: The cell address (in A1 notation) where this formula was
              defined (excluding the worksheet name).
 
    cóT—t|«\|_|_t|«|_y©N)rÚrowÚcolrÚ    tokenizer)ÚselfÚformulaÚorigins   rÚ__init__zTranslator.__init__-s#€ô1°Ó8шŒ$”(Ü" 7Ó+ˆrcó.—|jjS)z6Returns a list with the tokens comprising the formula.)rÚitems)rs rÚ
get_tokenszTranslator.get_tokens4s€à~‰~×#Ñ#Ð#rz*(\$?[1-9][0-9]{0,6}):(\$?[1-9][0-9]{0,6})$z&(\$?[A-Za-z]{1,3}):(\$?[A-Za-z]{1,3})$z'(\$?[A-Za-z]{1,3})(\$?[1-9][0-9]{0,6})$cóz—|jd«r|St|«|z}|dkr td«‚t|«S)zL
        Translate a range row-snippet by the given number of rows.
        ú$rúFormula out of range)Ú
startswithÚintr
Ústr)Úrow_strÚrdeltaÚnew_rows   rÚ translate_rowzTranslator.translate_row<sB€ð
× Ñ ˜cÔ "؈Nä˜'“l VÑ+ˆGؘ!Š|Ü%Ð&<Ó=Ð=ܐw“<Ð rcóˆ—|jd«r|S    tt|«|z«S#t$r t    d«‚wxYw)zN
        Translate a range col-snippet by the given number of columns
        r!r")r#rrÚ
ValueErrorr
)Úcol_strÚcdeltas  rÚ translate_colzTranslator.translate_colIsS€ð
× Ñ ˜cÔ "؈Nð >Ü(Ü,¨WÓ5¸Ñ>ó@ð@øäò >Ü%Ð&<Ó=Ð=ð >ús    •,¬AcóJ—d|vr|jdd«\}}|dz|fSd|fS)zCSplits out the worksheet reference, if any, from a range reference.ú!rÚ)Úrsplit)Ú    range_strÚsheets  rÚ strip_ws_namezTranslator.strip_ws_nameWs<€ð )Ñ Ø(×/Ñ/°°QÓ7Ñ ˆE9ؘ3‘;     Ð)Ð )ؐ9ˆ}Ðrcóö‡‡‡—‰j|«\}}‰jj|«}|I|‰j|j    d«‰«zdz‰j|j    d«‰«zS‰j
j|«}|I|‰j |j    d«‰«zdz‰j |j    d«‰«zSd|vr.|djˆˆˆfd„|jd«D««zS‰jj|«}|€|S|‰j |j    d«‰«z‰j|j    d«‰«zS)aV
        Translate an A1-style range reference to the destination cell.
 
        `rdelta`: the row offset to add to the range
        `cdelta`: the column offset to add to the range
        `range_str`: an A1-style reference to a range. Potentially includes
                     the worksheet reference. Could also be a named range.
 
        rú:éc3óD•K—|]}‰j|‰‰«–—Œy­wr)Útranslate_range)Ú.0Úpiecer-Úclsr's  €€€rú    <genexpr>z-Translator.translate_range.<locals>.<genexpr>s(øèø€ò&3àð×#Ñ# E¨6°6×:ñ&3ùsƒ )
r5Ú ROW_RANGE_REÚmatchr)ÚgroupÚ COL_RANGE_REr.ÚjoinÚsplitÚ CELL_REF_RE)r=r3r'r-Úws_partr@s` ``  rr:zTranslator.translate_rangeesvú€ð!×.Ñ.¨yÓ9шØ× Ñ ×&Ñ& yÓ1ˆØ Рؘc×/Ñ/°· ± ¸A³ÀÓGÑGÈ#ÑMØ×'Ñ'¨¯ © °A«¸Ó?ñ@ð Aà× Ñ ×&Ñ& yÓ1ˆØ Рؘc×/Ñ/°· ± ¸A³ÀÓGÑGÈ#ÑMØ×'Ñ'¨¯ © °A«¸Ó?ñ@ð Aà )Ñ ð ˜SŸX™Xõ&3à&Ÿ_™_¨SÓ1ô&3ó3ñ3ð 3ð—‘×%Ñ% iÓ0ˆØ ˆ=ØÐ ؘ#×+Ñ+¨E¯K©K¸«N¸FÓCÑCØ×#Ñ# E§K¡K°£N°FÓ;ñ<ð    =rNcó—|j«}|sy|djtjk(r|djSdg}|r,t |«\}}||j z
}||jz
}|D]„}|jtjk(rJ|jtjk(r-|j|j|j||««Œj|j|j«Œ†dj|«S)zÜ
        Convert the formula into A1 notation, or as row and column coordinates
 
        The formula is converted into A1 assuming it is assigned to the cell
        whose address is `dest` (no worksheet name).
 
        r1rú=)rÚtyperÚLITERALÚvaluerrrÚOPERANDÚsubtypeÚRANGEÚappendr:rC)    rÚdestÚ    row_deltaÚ    col_deltaÚtokensÚoutrrÚtokens             rÚtranslate_formulazTranslator.translate_formulaˆsá€ð—‘Ó"ˆÙØØ A‰Y^‰^œuŸ}™}Ò ,ؘ!‘9—?‘?Ð "؈eˆñ Ü*¨4Ó0‰HˆCØ˜dŸh™h™ˆIؘdŸh™h™ˆIØò    (ˆEØ—
‘
œeŸm™mÒ+Ø—M‘M¤U§[¡[Ò0Ø—
‘
˜4×/Ñ/°· ± ¸YØ09ó;õ<ð—
‘
˜5Ÿ;™;Õ'ð     (ðw‰ws‹|Ðr)Nrr)r r r rrrÚreÚcompiler?rBrEÚ staticmethodr)r.r5Ú classmethodr:rVrrrrr!sš„ñò,ò$ð2—:‘:ÐKÓL€Lؐ2—:‘:ÐGÓH€Lؐ"—*‘*ÐGÓH€Kàñ
 óð
 ðñ >óð >ðñ óð ðñ =óð =ôDrr) rrWrrrÚopenpyxl.utilsrrrÚ    Exceptionr
rrrrú<module>r]s4ðñó
ß'÷ñô iô ÷EòEr