• File: base.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/svgwrite/__pycache__/base.cpython-37.pyc
  • Date Modified: 11/23/2019 5:57 PM
  • File size: 8.04 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

s] @s|dZddlmZddlZddlmZddlmZmZm	Z	Gddde
ZGdd	d	e
ZGd
ddeZ
Gdd
d
eZdS)z7
The **BaseElement** is the root for all SVG elements.
)etreeN)	Parameter)AutoID
to_unicodePYTHON3c@seZdZdZdZddZddZddZed	d
Z	eddZ
ed
dZejddZeddZ
ddZd/ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd0d+d,Zd-d.ZdS)1BaseElementz
    The **BaseElement** is the root for all SVG elements. The SVG attributes
    are stored in **attribs**, and the SVG subelements are stored in
    **elements**.

    ZbaseElementcKs||dd}|dk	r|j|_nt|_|dd}|dk	rB||j_|dd}|dk	r^||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)selfZextrarr	r
r/base.py__init__s

zBaseElement.__init__cCs8x2|D]&\}}|ddd}|||q
WdS)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__)rrkeyvaluerrrrGs	zBaseElement.updatecCs@t|}t|j|_t|j|_d|jkr<||d<|S)Nid)copyrrnext_id)rZnewobjrrrrVs

zBaseElement.copycCs|jjS)N)rr	)rrrrr	^szBaseElement.debugcCs|jjS)N)rr
)rrrrr
bszBaseElement.profilecCs|jjS)N)r	validator)rrrrr!fszBaseElement.validatorcCs||j_dS)N)rr!)rrrrrr!jscCs
|jS)N)rZget_version)rrrrversionnszBaseElement.versioncCs
||_dS)N)r)rZ	parameterrrr
set_parameterrszBaseElement.set_parameterNcCs
t|S)N)rr )rrrrrr uszBaseElement.next_idcCs"d|jkr||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 )rrrrget_idxs
zBaseElement.get_idcCsd|S)zn
        Get the `IRI` reference string of the object. (i.e., ``'#id'``).

        :returns: `string`
        z#%s)r$)rrrrget_iriszBaseElement.get_iricCsd|S)zv
        Get the `FuncIRI` reference string of the object. (i.e. ``'url(#id)'``).

        :returns: `string`
        zurl(%s))r%)rrrrget_funciriszBaseElement.get_funciricCs
|j|S)zz Get SVG attribute by `key`.

        :param string key: SVG attribute name
        :return: SVG attribute value

        )r)rrrrr__getitem__szBaseElement.__getitem__cCs&|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!Zcheck_svg_attribute_valueelementnamer)rrrrrrrs	zBaseElement.__setitem__cCs(|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!Zcheck_valid_childrenr(rappend)relementrrraddszBaseElement.addcCs |}tj|dd}|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)rxmlZxml_utf8_strrrrr.szBaseElement.tostringcCs|S)z Show SVG in IPython, Jupyter Notebook, and Jupyter Lab

        :return: unicode XML string of this object and all its subelements

        )r.)rrrr
_repr_svg_szBaseElement._repr_svg_cCst|j}|jr$|j|j|jx8|jD]*\}}|dk	r0||}|r0|	||q0Wx|j
D]}||qfW|S)z Get the XML representation as `ElementTree` object.

        :return: XML `ElementTree` of this object and all its subelements

        N)
rElementr(r	r!Zcheck_all_svg_attribute_valuesrrvalue_to_stringsetrr)r-)rr0Z	attributerr*rrrr-s
zBaseElement.get_xmlcCsHt|ttfr@|jr"|j|dt|tr@|jdkr@t|d}t|S)z
        Converts *value* into a <string> includes a value check, depending
        on :attr:`self.debug` and :attr:`self.profile`.

        ZnumberZtiny)	
isinstanceintfloatr	r!Zcheck_svg_typer
roundr)rrrrrr3s
zBaseElement.value_to_stringcCs8|dk	r|jdt||dk	r4|jdt|dS)zK Insert a **title** and/or a **desc** element as first subelement.
        Nr)rinsertDescTitle)rtitledescrrrset_descszBaseElement.set_desccCsvt|}t|jdkr$|j|nNd}x:|j|jdkrb|d7}|t|jkr*|j|dSq*W|j||dS)zN
        :param xmldata: an xml.etree.ElementTree - Element() object.
        r)r=r>N)Metadatalenrr)r(r:)rxmldatametadataposrrrset_metadataszBaseElement.set_metadata)N)NN)__name__
__module____qualname____doc__r(rrrpropertyr	r
r!setterr"r#r r$r%r&r'rr+r.r1r-r3r?rFrrrrrs0+

	

rc@s eZdZdZddZddZdS)r<r=cCst|j|_t||j_dS)N)rr2r(r0rtext)rrMrrrrszTitle.__init__cCs|jS)N)r0)rrrrr-	sz
Title.get_xmlN)rGrHrIr(rr-rrrrr<sr<c@seZdZdZdS)r;r>N)rGrHrIr(rrrrr;
sr;c@seZdZdZddZdS)rArDcCstd|_|j|dS)zN
        :param xmldata: an xml.etree.ElementTree - Element() object.
        rDN)rr2r0r))rrCrrrrszMetadata.__init__N)rGrHrIr(rrrrrrAsrA)rJZsvgwrite.etreerrZsvgwrite.paramsrZsvgwrite.utilsrrrobjectrr<r;rArrrr<module>	sp