bg!dZddlmZddlZddlmZddlmZGddeZ Gdd eZ Gd d e Z Gd d e Z dS)z7 The **BaseElement** is the root for all SVG elements. )etreeN) Parameter)AutoIDceZdZdZdZdZdZdZedZ edZ edZ e j d Z ed Z d Zdd ZdZdZdZdZdZdZdZdZdZdZddZdZd S) BaseElementz The **BaseElement** is the root for all SVG elements. The SVG attributes are stored in **attribs**, and the SVG subelements are stored in **elements**. baseElementc ||dd}| |j|_nt|_|dd}| ||j_|dd}| ||j_t |_||t|_ dS)a :param extra: extra SVG attributes (keyword arguments) * add trailing '_' to reserved keywords: ``'class_'``, ``'from_'`` * replace inner '-' by '_': ``'stroke_width'`` SVG attribute names will be checked, if **debug** is `True`. workaround for removed **attribs** parameter in Version 0.2.2:: # replace element = BaseElement(attribs=adict) #by element = BaseElement() element.update(adict) factoryNdebugprofile) pop _parameterrr r dictattribsupdatelistelements)selfextrar r r s ^/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/svgwrite/base.py__init__zBaseElement.__init__s*))It,,  %0DOO(kkDO '4((  $)DO !))It,,  &-DO #vv  E c|D]D\}}|ddd}|||EdS)z Update SVG Attributes from `dict` attribs. Rules for keys: 1. trailing '_' will be removed (``'class_'`` -> ``'class'``) 2. inner '_' will be replaced by '-' (``'stroke_width'`` -> ``'stroke-width'``) _-N)itemsrstripreplace __setitem__)rrkeyvalues rrzBaseElement.updateHsc"--// ) )JC**S//))#s33C   S% ( ( ( (  ) )rctj|}tj|j|_tj|j|_d|jvr||d<|S)Nid)copyrrnext_id)rnewobjs rr$zBaseElement.copyWsZ44<00)DM22 6> ! !!>>++F4L rc|jjSN)rr rs rr zBaseElement.debug_s $$rc|jjSr()rr r)s rr zBaseElement.profilecs &&rc|jjSr(r validatorr)s rr-zBaseElement.validatorgs ((rc||j_dSr(r,rr!s rr-zBaseElement.validatorks$)!!!rc4|jSr()r get_versionr)s rversionzBaseElement.versionos**,,,rc||_dSr()r)r parameters r set_parameterzBaseElement.set_parameterss #rNc*tj|Sr()rr%r/s rr%zBaseElement.next_idvs~e$$$rcfd|jvr||jd<|jdS)z Get the object `id` string, if the object does not have an `id`, a new `id` will be created. :returns: `string` r#)rr%r)s rget_idzBaseElement.get_idys2 t| # #!%DL |D!!rc0d|zS)zn Get the `IRI` reference string of the object. (i.e., ``'#id'``). :returns: `string` z#%s)r8r)s rget_irizBaseElement.get_iris t{{}}$$rc0d|zS)zv Get the `FuncIRI` reference string of the object. (i.e. ``'url(#id)'``). :returns: `string` zurl(%s))r:r)s r get_funcirizBaseElement.get_funciris 4<<>>))rc|j|S)zz Get SVG attribute by `key`. :param string key: SVG attribute name :return: SVG attribute value )r)rr s r __getitem__zBaseElement.__getitem__s|C  rcj|jr!|j|j||||j|<dS)z Set SVG attribute by `key` to `value`. :param string key: SVG attribute name :param object value: SVG attribute value N)r r-check_svg_attribute_value elementnamer)rr r!s rrzBaseElement.__setitem__s> : S N 4 4T5EsE R R R! Src|jr%|j|j|j|j||S)z Add an SVG element as subelement. :param element: append this SVG element :returns: the added element )r r-check_valid_childrenrArappend)relements raddzBaseElement.addsH : W N / /0@'BU V V V W%%%rc|}tj|d}|dS)z Get the XML representation as unicode `string`. :return: unicode XML string of this object and all its subelements zutf-8)encoding)get_xmlrtostringdecode)rxml xml_utf8_strs rrJzBaseElement.tostrings9 llnn~cG<<< ""7+++rc*|S)z Show SVG in IPython, Jupyter Notebook, and Jupyter Lab :return: unicode XML string of this object and all its subelements )rJr)s r _repr_svg_zBaseElement._repr_svg_s }}rctj|j}|jr%|j|j|jt|jD]4\}}|-| |}|r| ||5|j D])}| | *|S)z Get the XML representation as `ElementTree` object. :return: XML `ElementTree` of this object and all its subelements )rElementrAr r-check_all_svg_attribute_valuesrsortedrvalue_to_stringsetrrDrI)rrL attributer!rEs rrIzBaseElement.get_xmls mD,-- : Z N 9 9$:JDL Y Y Y &t|'9'9';'; < < . . Iu ,,U33.GGIu---} * *G JJw(( ) ) ) ) rct|ttfrR|jr|j|dt|tr|jdkrt|d}t|S)z Converts *value* into a includes a value check, depending on :attr:`self.debug` and :attr:`self.profile`. numbertiny) isinstanceintfloatr r-check_svg_typer roundstrr/s rrTzBaseElement.value_to_stringss ec5\ * * (z ?--eX>>>%'' (DLF,B,BeQ5zzrc|(|jdt||*|jdt|dSdS)zK Insert a **title** and/or a **desc** element as first subelement. Nr)rinsertDescTitle)rtitledescs rset_desczBaseElement.set_descsZ   M DJJ / / /   M E%LL 1 1 1 1 1  rct|}t|jdkr|j|dSd}|j|jdvrM|dz }|t|jkr|j|dS|j|jdvM|j|jdkr'|j|j|dS|j||dS)N :param xmldata: an xml.etree.ElementTree - Element() object. r)rerfNmetadata)MetadatalenrrDrArLrb)rxmldatarkposs r set_metadatazBaseElement.set_metadatasG$$ t}   " " M  * * * * *C-$04EEEq#dm,,,,M((222F -$04EEE }S!-;; c"&--g66666 $$S(33333rr()NN)__name__ __module__ __qualname____doc__rArrr$propertyr r r-setterr2r5r%r8r:r<r>rrFrJrOrIrTrgrprrrrs  K)))V ) ) )%%X%''X'))X)***--X-$$$%%%%"""%%%***!!! " " "    , , ,(   222244444rrceZdZdZdZdZdS)rdrecttj|j|_t ||j_dSr()rrQrArLr`text)rrzs rrzTitle.__init__ s)=!122D  rc|jSr()rLr)s rrIz Title.get_xml s xrN)rqrrrsrArrIrwrrrdrds7K"""rrdceZdZdZdS)rcrfN)rqrrrsrArwrrrcrcsKKKrrcceZdZdZdZdS)rlrkcltjd|_|j|dS)rirkN)rrQrLrD)rrns rrzMetadata.__init__s/=,,      rN)rqrrrsrArrwrrrlrls(K!!!!!rrl) rtsvgwrite.etreerr$svgwrite.paramsrsvgwrite.utilsrobjectrrdrcrlrwrrrs ! %%%%%%!!!!!!o4o4o4o4o4&o4o4o4dF5!!!!!u!!!!!r