ok

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/svgwrite/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/svgwrite/__pycache__/base.cpython-37.pyc

B

s�] �@s|dZddlmZddlZddlmZddlmZmZm	Z	Gdd�de
�ZGdd	�d	e
�ZGd
d�de�Z
Gdd
�d
e�ZdS)z7
The **BaseElement** is the root for all SVG elements.
�)�etreeN)�	Parameter)�AutoID�
to_unicode�PYTHON3c@s�eZdZdZdZdd�Zdd�Zdd�Zed	d
��Z	edd��Z
ed
d��Zejdd��Zedd��Z
dd�Zd/dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd0d+d,�Zd-d.�ZdS)1�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**.

    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)

        �factoryN�debug�profile)
�pop�
_parameterrr	r
�dict�attribs�update�list�elements)�selfZextrarr	r
�r�/base.py�__init__s

zBaseElement.__init__cCs8x2|��D]&\}}|�d��dd�}|�||�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)�items�rstrip�replace�__setitem__)rr�key�valuerrrrGs	zBaseElement.updatecCs@t�|�}t�|j�|_t�|j�|_d|jkr<|��|d<|S)N�id)�copyrr�next_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
|j��S)N)rZget_version)rrrr�versionnszBaseElement.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 )rrrr�get_idxs
zBaseElement.get_idcCsd|��S)zn
        Get the `IRI` reference string of the object. (i.e., ``'#id'``).

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

        :returns: `string`
        zurl(%s))r%)rrrr�get_funciri�szBaseElement.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_value�elementnamer)rrrrrrr�s	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(r�append)r�elementrrr�add�szBaseElement.addcCs |��}tj|dd�}|�d�S)z� Get the XML representation as unicode `string`.

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

        zutf-8)�encoding)�get_xmlr�tostring�decode)r�xmlZ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_cCs�t�|j�}|jr$|j�|j|j�x8|j��D]*\}}|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)
r�Elementr(r	r!Zcheck_all_svg_attribute_valuesrr�value_to_string�setrr)r-)rr0Z	attributerr*rrrr-�s
zBaseElement.get_xmlcCsHt|ttf�r@|jr"|j�|d�t|t�r@|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�)	�
isinstance�int�floatr	r!Zcheck_svg_typer
�roundr)rrrrrr3�s
zBaseElement.value_to_stringcCs8|dk	r|j�dt|��|dk	r4|j�dt|��dS)zK Insert a **title** and/or a **desc** element as first subelement.
        Nr)r�insert�Desc�Title)r�title�descrrr�set_desc�szBaseElement.set_desccCsvt|�}t|j�dkr$|j�|�nNd}x:|j|jdkrb|d7}|t|j�kr*|j�|�dSq*W|j�||�dS)zN
        :param xmldata: an xml.etree.ElementTree - Element() object.
        r)r=r>�N)�Metadata�lenrr)r(r:)r�xmldata�metadata�posrrr�set_metadata�szBaseElement.set_metadata)N)NN)�__name__�
__module__�__qualname__�__doc__r(rrr�propertyr	r
r!�setterr"r#r r$r%r&r'rr+r.r1r-r3r?rFrrrrrs0+

	

rc@s eZdZdZdd�Zdd�ZdS)r<r=cCst�|j�|_t|�|j_dS)N)rr2r(r0r�text)rrMrrrrszTitle.__init__cCs|jS)N)r0)rrrrr-	sz
Title.get_xmlN)rGrHrIr(rr-rrrrr<sr<c@seZdZdZdS)r;r>N)rGrHrIr(rrrrr;
sr;c@seZdZdZdd�ZdS)rArDcCst�d�|_|j�|�dS)zN
        :param xmldata: an xml.etree.ElementTree - Element() object.
        rDN)rr2r0r))rrCrrrrszMetadata.__init__N)rGrHrIr(rrrrrrAsrA)rJZsvgwrite.etreerrZsvgwrite.paramsrZsvgwrite.utilsrrr�objectrr<r;rArrrr�<module>	sp

Zerion Mini Shell 1.0