Ȯ$idZddlmZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZddldZe e e e ee ee e e iZdZedd Zd Zeeeeeeeed Zgd Zd Z ddZ!Gdde"Z#Gddee#Z$dZ%dZ&Gddee#Z'idddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d d5id6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZZ(ddefdd/e fd1d@efd[d\efdBdPe fdRdVefd]d]e fd^d^e fd_d`efdadbe fdcdde fdedfefg Z)iZ*e)D]\Z+Z,Z-e.e+e,dzD]Z/e-e*e/< [+[,[-[/e0dgZ1iZ2e1e1jgzD]Z4de2e4< [4[1iZ5e0dhD]Z4de5e4< e0dde0dide0djdiZ6e0d,de0dXde0dde0dkde0dlde0dYdiZ7ejpdmjrZ:dnZ;efdoZdrZ?dsZ@dtZAduZBdvZCdwZDGdxdyee#ZEGdzd{ee#ZFGd|d}ee#ZGGd~dee#ZHGddeZIy)z$ Module for formatting information. )print_functionN)unpack)FDTFGEFNUFTXFUN XL_CELL_DATEXL_CELL_NUMBER XL_CELL_TEXT XL_FORMAT XL_FORMAT2 BaseObject XLRDErrorfprintf unpack_stringunpack_unicodeupkbitsupkbitsL)*)8rrrrrrrrrrrrrrrrrrrrrrrrrrr"rrrr"r"r"rr"rr"rr"r"r)r)r"r"r"r,rr,3frrr1rrr/rr/rr"r"rr/r1r1r1rr$rrr r&r!r'rrr1rr2r1rr1rrr,r,r1rrr,r1r1r,r)r=r=r.r/rr.r1r1r,r1rrr1rrr,rrr/rr/r/r,rFrFrr.r/r.r,r/rr.rr.r.rr,r.rr-r.r.r,r.r.r.)8rrrrrrrr r!r#r$r%r&r'r(r*r+r-r0r2r3r4r5r6r$rrr r&r!r'rr7r2r8r9r:r;r<)rr1r,r>r?r@rArBrCrDrErGrHrIrJrKr-rLrM)PF2-() Normal RowLevel_ ColLevel_CommaCurrencyPercentz Comma [0]z Currency [0] HyperlinkzFollowed Hyperlinkci|_i|_|jsytdD]}t||j|<t |j }t|}t|D]}|||j|dz<d|j|dz<d|j|dzdz<d|jd<d|jd<y)NrQ) colour_mapcolour_indexes_usedformatting_infoxrangeexcel_default_palette_b8default_palette biff_versionlen)bookidpalndpals U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/xlrd/formatting.pyinitialise_colour_maproisDO!D    AY95a89 4,, -D IE E]'#Aw!' $DOOE!G!%DOOE!GAI DOOD"DOOFcd}d}|jD]=\}}| d}t||D]\}} ||| z || z zz }||ks3|}|}|dk(s=n |S)z General purpose function. Uses Euclidean distance. So far used only for pre-BIFF8 ``WINDOW2`` record. Doesn't have to be fast. Doesn't have to be fancy. ir)itemszipprint) rbrgbdebug best_metric best_colourxcolourxcand_rgbmetricv1v2s rnnearest_colour_indexr~s KL'--/    #x( ,FB rBw27+ +F , K  K"L{   rpceZdZdZdZdZy) EqNeAttrsz This mixin class exists solely so that :class:`Format`, :class:`Font`, and :class:`XF` objects can be compared by value of their attributes. c4|j|jk(SN__dict__selfothers rn__eq__zEqNeAttrs.__eq__}}..rpc4|j|jk7Srrrs rn__ne__zEqNeAttrs.__ne__rrpN)__name__ __module__ __qualname____doc__rrrprnrrs //rprcXeZdZdZdZdZdZdZdZdZ dZ dZ e dZ dZdZdZdZdZdZy)Fontz An Excel "font" contains the details of not only what is normally considered a font, but also several other display attributes. Items correspond to those in the Excel UI's Format -> Cells -> Font tab. .. versionadded:: 0.6.1 rN)rrrrbold character_set colour_index escapementfamily font_indexheightitalicUNICODE_LITERALname struck_outunderline_type underlinedweightoutlineshadowrrprnrrsu D0MLJFJFF 2 DJNJFGFrprc`|jsytd|d|jd_y)NCrPGr`ymdhsz$-+/(): #?GENERALgeneralz \[[^]]*\]cd}d}|D]d}|dk(r0|tdk(rd}n<|tdvrd}n,|tvrn#||z }n|dk(r|tdk(r d}n|dk(rd}d|cxkrdkraJJ|jdk\r#tdt |z|j t d|}|tvry d}d }d}dx}}|D]4}|tvr |t|z }|tvr |t|z }-||k(s3d}6|r|sy |r|sy |r*|jrt|j d |||||kDS|s#|jrt|j d|||kDS)Nrr"rz\_*rrz+is_date_format_string: reduced format is %sfileF;Tz7WARNING *** is_date_format: ambiguous d=%d n=%d fmt=%r z/WARNING *** format %r produces constant result ) rskip_char_dictrrtREPRrfmt_bracketed_subnon_date_formatsdate_char_dict num_char_dictr) rjfmtstatesc separatorgot_sep date_count num_counts rnis_date_format_stringrs E A  A:OC((of--n$Q aZOC(( aZEEQ!" ~~ ;d1gEDLLY"a A  EIGJ    .+ +J -  q) )I )^G ) >> DLLJIs ,  !!  >> DLLB   !!rpcd}|j}|tk(r t|d}|js|j d}|dk\rt d|ddd}n|j }|dkrd}|xj dz c_|dk\r t|d}nt|||jd}|xs|jd k\}|r$t|jd |j ||||j|} ttg| } |d kDsa|dks\tj!|t"} | tk(} |jr-d|cxkrdkr"nn| | z rd}t|jd |||dk(rt|jd |  | |t%|| |} |r.| j'|jd|j dz fz| |j(|<|j*j-| y)NrrTrrQrrrOrrz)FORMAT: count=%d fmtkey=0x%04x (%d) s=%r zHWARNING *** Conflict between std format key %d and its format string %r z2ty: %d; is_date_c: %r; is_date_s: %r; fmt_strg: %rz--- handle_format [%d] ---)r)rhrminrrractualfmtcountrrrrrrrrstd_format_code_typesgetr rr format_map format_listr)rrrectyperrstrposfmtkeyunistrgr is_date_srstd_ty is_date_cfmtobjs rn handle_formatr s E  B* R[ ==  F Rxd1Qi(+$$ 8F1 Rx q)fdmmAF  'DNNa'D  8    :**73I sI B C<27'**637cM >>a&o2o9y3HE DLL? ! z @  9g /FB (F  DLL/43F3Fq3H2KK  M$DOOFF#rpc|jsytxs|jdk\}td|dd\}d|jdk\}ts|jdk\r||k7rt |j d||n|rt |j d|d|z}d |zdz}t|}d }||cxkr||zksntd ||fzt||d|} |jgk(sJt|D]} | | } | d z} | d z d z} | d z d z}|jd | z}| | |f}|jj|||jd | z<|sd||k7sjtd| ||fz|j y)Nrr)rN8rQrz9NOTE *** Expected %d colours in PALETTE record, found %d zPALETTE record with %d colours z %rr)rdrrrrhrrrirpalette_recordrerbrrt)rjrr n_coloursexpected_n_coloursr expected_size actual_size tolerancecoloursrkrredgreenblueold_rgbnew_rgbs rnhandle_paletter%As     'DNNa'Dd2Ah'JI!$"3"3r"9: 1$)7I*I H   +  .  ; Y C MA%Md)KI K D=9+D DJm]hMiijjS$~ ./G   " $$ $I  R AJDqD bD //!A#&t$ ""7+&! '!oGW(==DLLQ Rrpc |jD]}|jdk(r|j}|dk(r%||jvrd|j|<C|j sPt dt|j|jt|jd|j|j||j dk\r>t|jj}t d|z|jyy)NrrarzSize of colour table:rz2*** Font #%d (%r): colour index 0x%04x is unknown z Colour indexes used: %r ) rrrrbrcrrtrirrrsortedkeys)rjfontcxuseds rnpalette_epiloguer,es 0 ??a      <   +,D $ $R ( ^^ )3t+?dll S DLL"WB 0 0 ~~d..3356 ,t3$,,Grpc |jsytxs|jdk\}|j}t d|dd\}}}|dz}|dk(rd|j vr d}d}d}d} d }n|d zr+d}t |} d|cxkrdkrdnna| t|dzz } nOd}d}d}|d k\r t|dd } nt|d|jd } |r| std|j||f|j | <|rt|jd||||| yy#t$rDtd ||||fz|jtdt|dd|jwxYw)Nrz?EI\\SlDabNF  s #DA E#c`t|jj}|D]\}}t|drt ||| |j ddk\s5||j vrd|j|<S|jj}td||||fz|jy)Nrrrrz&*** xf #%d : %s.%s = 0x%04x (unknown)r) r'rrrhasattrcheck_colour_indexes_in_objfindrbrc __class__rrtr)rjobj orig_indexalistattrnobjonames rnr<r<s 3<<%%' (E F d 4 'dJ ? YY~ &! +t&12((.MM**E :udD128<  F FrpctjD]K}||jvst|}tj |}t |||}||j|<Myr)r r(r std_format_stringsr r)rjxrfmt_strrs rnfill_in_standard_formatsrIs^ " ' ' )( DOO #&q)B),,Q/GAr7+F!'DOOA (rpc Xtxs|jdk\}|j}t}t |_d|j _d|j _d|j _t|_ d|j_ d|j_ d|j_ d|j_t|_t#|_|dk\r|j&s t)||dk\rd}t+||dd\ |_|_}}|j _}} } } } t3|j$|dt3||dt3|j |d t3|j |d | d z } gd }|D]}d |zdz}t5||| dz| dz} !t7|j| dt3|j| dt7|j | dt3|j | dn|dk\rd}t+||dd\|_|_}}}} } t3|j$|dt3||dt3|j |d |dz}gd||j _|d z } gd }|D]}d |zdz}t5||| dz| dz} !t7|j | dt7|j| dt3|j| dn|dk\rd}t+||dd\|_|_}}} }}t3|j$|dt3||dt3|j |d|dzdz }gd||j _| d z } gd }|D]}d |zdz}t5||| dz| dz} !t3|j |d t7|j|d!n|d"k(rd#}t+||dd\|_|_}} }}}t3|j$|dt3||d$t3|j |d%t3||d&| d z } gd }|D]}d |zdz}t5||| dz| dz} !t3|j |d t7|j|d!d |j _d|j _n'|d'k(rt+d(|\|_}}|d)z|_t3|j$|d*t3|j |d+d,D]I\}}||zrd-\}}nd.\}}t5|j|d/z|t5|j|d0z|K|j }|d1zrd2|_nd|_d3|_d4|_d|_ d |j _d|j _gd }|D]}d |zdz}t5||dntCd5|ztE|jF|_$|jFjK||xj&dz c_|r+|jM|jNd6|jHzd78 |jP|j.}tR|jT} | |jZ|jH<|j\rl|jrI|j^r=|j@d9k7r.d:}!ta|jN|!|jH|j@tc|||jH|j.|jPvrMd;}!|jr7ta|jN|!|jH|j.|j.d|_yy#tV$r tX} Y wxYw) " $ I?W,D BcAg & AIC   .  K*    ;)   r :tAbz *  M2=, h   |.   L#   .1  ($.14 1+ > !m $ I?W,D BcAg & AIC   z,  J )  r :tAbz *  M2=- m   }/   M$    m.   M$  !m $ I?W,D BcAg & AIC   z,  J ) #$  !  r 39$2G/ J"T)  z,    j+  ] AJD$D +/( j+/( j BIIto5| D BIItm3Z @  A]]   BOBO%&""# !"#  !  $ !I?W,D Ba  !4r9::dll#BKLLLLAL   LL.<   oobmm,#CHH-28D!!"++.  >>bkkb.C.Cv.McC DLL#r{{B4I4I J#D"bkk: }}DOO+J >> DLL# R]]BMM ; ,   s3,^^)(^)c Ld|_t|j}txs|jdk\}txs|jdk\}|rt |j dd}t|D]}|j|} |j|j}t|j}||j|j<|j sf|j"rsd|j$cxkr|ksBn|r7t |j d|j|j"|j$d|_|j&dk\s|r|j$|jk(r-t |j d|j|j$nO|j|j$j"s,t |j d |j|j$|rE|j$|jkDr,t |j d |j|j$|j|j$} |j(s| j(s |r |||| d |j*s| j*s |r |||| d |j,s| j,s |r |||| d |j.s| j.s |r |||| d|j0s| j0s|r|j| jk7rt |j d|j|j| j| j|j|jj2|j| jj2|j4r,| j4r:|s>|j6| j6k7sYt |j d|j|j6| j| j6y#t$r t}YqwxYw)Nrrzxf_epilogue called ... ct||t||k7r.t|jd|j|j|yy)Nz(NOTE !!! XF[%d] parent[%d] %s different )getattrrrr7)book_argxf_arg parent_argrBs rn check_samezxf_epilogue..check_samesA 64 GJ$= = H$$;!4!4d < >rprz:WARNING *** XF[%d]: is_style=%d but parent_style_index=%d rTz/NOTE !!! XF[%d]: parent_style_index is also %d z>NOTE !!! XF[%d]: parent_style_index is %d; style flag not set z9NOTE !!! XF[%d]: parent_style_index is %d; out of order? r]r_r^r`z4NOTE !!! XF[%d] fmtk=%d, parent[%d] fmtk=%r %r / %r z.NOTE !!! XF[%d] fontx=%d, parent[%d] fontx=%r )_xf_epilogue_donerirrrrrrer rrrrr rr7rdrNrRrh_alignment_flag_background_flag _border_flag_protection_flag _format_flagr _font_flagr) rnum_xfsrblah1rxfxrrrparents rn xf_epiloguersDD$,,G  'DNNa'D  (T^^q(E  89<g7X \\#  "//"--0C'1F6<%%bkk2##  ;; B))3G3 QKKb.C.CE%&B !    "((BKK7DLLJ R%:%:<b&;&;<EEDLLY R%:%:<..< PKK!6!68\\""7"78F%%f.D.D*T2v{C&&v/F/F*T2v|D??6+>+>*T2vx@&&v/F/F*T2v|D??6+>+>R]]f.?.??DLLP R]]FOOVEVEV 6AA(9(9:EE G ==):):R]]f.?.??DLLI R]]FOOVEVEVXk7X  "!F "s,PP#"P#c t|d|_tttt t ttttf }|D]#}t|j|j|%y)Nr)rorrrrrr%r,r9rrrr>r)rjmethodsmethods rninitialise_bookrAsY$D G989rpc@eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZy)rao A collection of the border-related attributes of an ``XF`` record. Items correspond to those in the Excel UI's Format -> Cells -> Border tab. An explanations of "colour index" is given in :ref:`palette`. There are five line style attributes; possible values and the associated meanings are:: 0 = No line, 1 = Thin, 2 = Medium, 3 = Dashed, 4 = Dotted, 5 = Thick, 6 = Double, 7 = Hair, 8 = Medium dashed, 9 = Thin dash-dotted, 10 = Medium dash-dotted, 11 = Thin dash-dot-dotted, 12 = Medium dash-dot-dotted, 13 = Slanted medium dash-dotted. The line styles 8 to 13 appear in BIFF8 files (Excel 97 and later) only. For pictures of the line styles, refer to OOo docs s3.10 (p22) "Line Styles for Cell Borders (BIFF3-BIFF8)".

.. versionadded:: 0.6.1 rN)rrrrrqrsrirlrtrfrgrcrerurmrorrprnrrRsa@NOOIGrprceZdZdZdZdZdZy)ra A collection of the background-related attributes of an ``XF`` record. Items correspond to those in the Excel UI's Format -> Cells -> Patterns tab. An explanations of "colour index" is given in :ref:`palette`. .. versionadded:: 0.6.1 rN)rrrrrwr{ryrrprnrrsL rprc,eZdZdZdZdZdZdZdZdZ dZ y)rz A collection of the alignment and similar attributes of an ``XF`` record. Items correspond to those in the Excel UI's Format -> Cells -> Alignment tab. .. versionadded:: 0.6.1 rN) rrrrrTrXrrVrYrZr[rrprnrrs8IJHLLMNrprceZdZdZdZdZy)rad A collection of the protection-related attributes of an ``XF`` record. Items correspond to those in the Excel UI's Format -> Cells -> Protection tab. Note the OOo docs include the "cell or style" bit in this bundle of attributes. This is incorrect; the bit is used in determining which bundles to use. .. versionadded:: 0.6.1 rN)rrrrrKrLrrprnrrsKNrprcLeZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZy)ra eXtended Formatting information for cells, rows, columns and styles. Each of the 6 flags below describes the validity of a specific group of attributes. In cell XFs: - ``flag==0`` means the attributes of the parent style ``XF`` are used, (but only if the attributes are valid there); - ``flag==1`` means the attributes of this ``XF`` are used. In style XFs: - ``flag==0`` means the attribute setting is valid; - ``flag==1`` means the attribute should be ignored. .. note:: the API provides both "raw" XFs and "computed" XFs. In the latter case, cell XFs have had the above inheritance mechanism applied. .. versionadded:: 0.6.1 rN)rrrrrNrRrrrrrrr7rrr`r_r]r^rrprnrrsq4H LJOLHJJJJIFrpr)r)Jr __future__rrestructrbiffhrrrr r r r r rrrrrrrrr timemachinerrexcel_default_palette_b5excel_default_palette_b2rfrgr0ror~objectrrrrrrFfmt_code_rangesr lohirrerGr date_charsrupper_crrrcompilesubrrrr%r,r9r<rIrrrrrrrrrrprnrs&    "4CR8$ !        * #02 / /Y:yYv< E R%Z%:( ) (  # (  & ( '( *( ( "( #( (( $( '( *(  '!(" )#($ (%(& *'(( ')(* (+(, ,-(. //(0 &1(2 )3(4 -5(6 7(8 9(: !;(< &=(> 5?(@ 8A(B =C(D @E(F 'G(H +I(J )K(L  O(Z!SMSMSMSMSMSMSMSMSMSMSMSM$!&JBB B1 &#%a &&B W %  z'') )BN2  * %BN2C!C!C! JJIIIC BJJ|,00="~'00$h"RHH():V F (zx GXR9"Az9AF:y( *i D:y&NNrp