U o^@sddlmZddlmZeeZddlmZddlmZddlm Z m Z m Z ddl m Z ddlmZdd lmZmZeefZGd d d eZd S) )copy)kwlist) Descriptor)_Serialiasable)SequenceNestedSequenceMultiSequencePart) namespaced) safe_string)Element localnamec@seZdZdZdZdZdZdZdZe ddZ dZ e ddZ ddd Zd d Zd d ZddZddZddZddZddZdS) Serialisablea Objects can serialise to XML their attributes and child objects. The following class attributes are created by the metaclass at runtime: __attrs__ = attributes __nested__ = single-valued child treated as an attribute __elements__ = child elements NrcCstdSN)NotImplementedError)selfr{/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/openpyxl/openpyxl/descriptors/serialisable.pytagname(szSerialisable.tagnamec Cst|j}|jD]"\}}||kr||||<||=qt|D]\}|drR||=q<|tkrr|||d|<||=qsz'Serialisable.to_tree..)rrr r#rrr r"r r! __elements__ __class__r&r3r$ seq_typesrr4ridx_baser( __nested__) rridxr3attrsr,r-r/r1r2Znodesr+rr7rr4jsL                zSerialisable.to_treeccs|jD]x}t||}|dr,|dd}n4|dkr`d|kr`t|j|}t|ddr`|dd}|dkr|dk r|t|fVqdS)NrrrZ hyphenatedFr)r"r#rr:r r )rattrvaluer1rrr__iter__s      zSerialisable.__iter__cCsN|j|jksdSt|t|ks$dS|jD]}t||t||kr*dSq*dS)NFT)r:rr9r#)rotherr/rrr__eq__s  zSerialisable.__eq__cCs ||k Srr)rrCrrr__ne__szSerialisable.__ne__cCsnd|j|jj}g}|j|jD]2}t||}t|tr>d}| d|t |q"d |}d ||gS)Nz<{0}.{1} object> Parameters:z{0}={1}z,  ) format __module__r:__name__r"r9r#r$rr(reprjoin)rsargskr6rrr__repr__s   zSerialisable.__repr__cCsHg}|j|jD]*}t||}t|tr0t|}||qtt|Sr)r"r9r#r$rtupler(hash)rfieldsr@valrrr__hash__s   zSerialisable.__hash__cCst|t|krtdi}|jD]}t||p8t||||<q"|jD]:}t||}t||}|rt|rt||||<qF|pz|||<qF|jf|S)Nz+Cannot combine instances of different types)type TypeErrorr"r#r9r:)rrCvalsr@r/abrrr__add__s    zSerialisable.__add__cCsR|jdd}|j|}|jD].}||j|jkrtt||}t|||q|S)Ndummy)r) r4r:r__dict__r"r9rr#setattr)rxmlcprNr6rrr__copy__s   zSerialisable.__copy__)NNN)rIrH __qualname____doc__r"r=r9rr<r%rr3 classmethodrr4rBrDrErOrTrZr`rrrrrs&  ; 6   rN)rkeywordr frozensetrrrsequencerrr r3r Zopenpyxl.compatr Zopenpyxl.xml.functionsr r rrPr;rrrrrs