"VfiR dZddlmZddlmZddlmZddlmZddlm Z m Z m Z m Z m Z mZddlmZddlmZmZmZd d lmZGd d eeZGd deZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZ eded ed!ed"ed#e d$iZ!d%e!"DZ#Gd&d'eZ$d(S))uDImplementation of custom properties see § 22.3 in the specification)warn)Strict) Serialisable)Sequence)AliasStringIntegerFloatDateTimeBool) NestedText) CUSTPROPS_NS VTYPES_NS CPROPS_FMTID)NestedDateTimeceZdZdZdS)NestedBoolTextzX Descriptor for handling nested elements with the value stored in the text part N)__name__ __module__ __qualname____doc__Hc:\PYTHON\DbComparer\venv\Lib\site-packages\openpyxl/packaging/custom.pyrr s Drrc6eZdZdZdZdZedZee de Z ee de Z eede Zede Zeede Zee dZeZeZdd edfd Zed Zd fd ZxZS)_CustomDocumentPropertyz Low-level representation of a Custom Document Property. Not used directly Must always contain a child element, even if this is empty propertyNT allow_none) expected_typer namespace)r r")r!r rc ||_||_||_d|_||_|D]'\}}t |||t |d|(|jD]}||vrt ||ddS)N_typ)fmtidpidnamer$ linkTargetitemssetattr __elements__) selfr'r&r%r(kwkves r__init__z _CustomDocumentProperty.__init__=s    $HHJJ % %DAq D!Q    D&! $ $ $ $" ' 'A{{a&&& ' 'rcp|j|jS|jD]}t|||cS|jdSdS)Nr()r$r+getattrr()r,as rtypez_CustomDocumentProperty.typeQsW 9 9 "  AtQ+, ? &< ' &rct||jd}|t||jdtdddS)N)tagnameidxr")r3r$r*superto_tree)r,r8r9r"child __class__s rr;z_CustomDocumentProperty.to_tree\sKdi.. = D$)R ( ( (wwtFFFrNNN)rrrrr8r$rr'r strrlpwstrinti4floatr8rfiletimerboolr(r%r r&rr1rr5r; __classcell__r=s@rrr(sB G D 6T " " "D Zcdi P P PF #$) L L LB %DI N N NB~CCCH > S S SDcd;;;J FHHE '))C# ''''(  X GGGGGGGGGGrrcfeZdZdZdZeeeZe dZ d dZ dZ d fd Z xZS) _CustomDocumentPropertyListzG Parses and seriliases property lists but is not used directly Properties)r!r"rrc||_dSNr)r,rs rr1z$_CustomDocumentPropertyList.__init__ps   rc*t|jSrM)lenrr,s r__len__z#_CustomDocumentPropertyList.__len__ts4=!!!rNct|jdD] \}}||_ t|||}|dt |S)Nxmlns) enumeraterr&r:r;setr)r,r8r9r"ptreer=s rr;z#_CustomDocumentPropertyList.to_treexs] q11  FCAEEwwwY77 ,''' r)rr>)rrrrr8rrrrr customPropsr1rRr;rGrHs@rrJrJdsGx&=VVVH% ##K!!!!"""rrJc4eZdZeZdZdZdZdS)_TypedPropertyc"||_||_dSrMr'value)r,r'r_s rr1z_TypedProperty.__init__s  rcB|j|jko|j|jkSrMr^)r,others r__eq__z_TypedProperty.__eq__syEJ&D4:+DDrc>|jjd|jd|jS)Nz, name=z, value=)r=rr'r_rQs r__repr__z_TypedProperty.__repr__s'.)QQ$)QQTZQQQrN)rrrrr'r1rbrdrrrr\r\sT 688DEEERRRRRrr\c"eZdZeZdS) IntPropertyN)rrrr r_rrrrfrfs GIIEEErrfc"eZdZeZdS) FloatPropertyN)rrrr r_rrrrhrhs EGGEEErrhc&eZdZedZdS)StringPropertyTrNrrrrr_rrrrjrjs Fd # # #EEErrjc"eZdZeZdS)DateTimePropertyN)rrrr r_rrrrmrms HJJEEErrmc"eZdZeZdS) BoolPropertyN)rrrr r_rrrroros DFFEEErroc"eZdZeZdS) LinkPropertyNrkrrrrqrqs FHHEEErrqr@rBrDrErFr(ci|]\}}|| Srr).0r.r/s r rts444sqq444rceZdZeeZdZedZdZ dZ dZ e dZ dZd Zd Zd Zd S) CustomPropertyList)r!cg|_dSrMpropsrQs rr1zCustomPropertyList.__init__s  rct|}g}|jD]}|j}t|d}|st d|j>t||}|j }|t}|j }||j|} | | |} || _ | S)z0 Create list from OOXML element NzUnknown type for r^) rJ from_treerr5 XML_MAPPINGgetrr'r3r(rqappendry) clsrY prop_listrypropattrtypr_linknew_prop new_prop_lists rr{zCustomPropertyList.from_trees 099$?? & # #D9D//$--C 444555D$''E?D"s 777H LL " " " " # rc|j|jvrtd|jd|j|dS)NProperty with name z already exists)r'names ValueErrorryr~)r,rs rr~zCustomPropertyList.appendsI 9 " "M49MMMNN N $rcZg}|jD]~}t|jd}|st dt dd|ji||ji}t|trd|_ | |t|}| S)NzUnknown adapter for {p}r'r@rNr)ry CLASS_MAPPINGr}r= TypeErrorrr'r_ isinstancerqr$r~rJr;)r,ryrXrnprs rr;zCustomPropertyList.to_trees  A $$Q[$77D ; 9:::(GGafGagGGB!\** #" LL    /???   """rc*t|jSrM)rPryrQs rrRzCustomPropertyList.__len__s4:rc$d|jDS)zList of property namescg|] }|j Sr)r')rsrXs r z,CustomPropertyList.names..s+++1+++rrxrQs rrzCustomPropertyList.namess,+ ++++rcZ|jD]}|j|kr|cStd|d)z& Get property by name r not found)ryr'KeyError)r,r'rXs r __getitem__zCustomPropertyList.__getitem__sH  Av~~=T===>>>rct|jD]-\}}|j|kr|j|dS.t d|d)z* Delete a propery by name Nrr)rVryr'popr)r,r'r9rXs r __delitem__zCustomPropertyList.__delitem__sh  ++  FCv~~ s###=T===>>>rc.|jjd|jS)Nz containing )r=rryrQs rrdzCustomPropertyList.__repr__s.)CCtzCCCrc*t|jSrM)iterryrQs r__iter__zCustomPropertyList.__iter__ sDJrN)rrrrr\ryr1 classmethodr{r~r;rRrrrrrdrrrrrvrvs H> 2 2 2E[8   ###",,X, ??????DDD     rrvN)%rwarningsropenpyxl.descriptorsr!openpyxl.descriptors.serialisableropenpyxl.descriptors.sequencerrrr r r r openpyxl.descriptors.nestedr openpyxl.xml.constantsrrrcorerrrrJr\rfrhrjrmrorqrr)r|rvrrrrsIKJ''''''::::::222222 !      T:   9G9G9G9G9Gl9G9G9Gx,:RRRRRVRRR&. N $$$$$^$$$ ~ > >H4j&,  54m1133444 b b b b b b b b b b r