ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/svgwrite/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/svgwrite/__pycache__/base.cpython-311.pyc

�

�܋f�!���dZddlmZddlZddlmZddlmZGd�de��Z	Gd�d	e��Z
Gd
�de
��ZGd�d
e
��ZdS)z7
The **BaseElement** is the root for all SVG elements.
�)�etreeN)�	Parameter)�AutoIDc��eZdZdZdZd�Zd�Zd�Zed���Z	ed���Z
ed���Zejd	���Zed
���Z
d�Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd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)

        �factoryN�debug�profile)
�pop�
_parameterrrr�dict�attribs�update�list�elements)�self�extrar
rrs     �D/opt/cloudlinux/venv/lib64/python3.11/site-packages/svgwrite/base.py�__init__zBaseElement.__init__s���*�)�)�I�t�,�,����%�0�D�O�O�(�k�k�D�O��	�	�'�4�(�(����$)�D�O�!��)�)�I�t�,�,����&-�D�O�#��v�v������E��������
�
�
�c��|���D]D\}}|�d���dd��}|�||���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)�items�rstrip�replace�__setitem__)rr�key�values    rrzBaseElement.updateHsc��"�-�-�/�/�	)�	)�J�C���*�*�S�/�/�)�)�#�s�3�3�C����S�%�(�(�(�(�		)�	)rc���tj|��}tj|j��|_tj|j��|_d|jvr|���|d<|S)N�id)�copyrr�next_id)r�newobjs  rr$zBaseElement.copyWsZ����4������4�<�0�0����)�D�M�2�2����6�>�!�!�!�>�>�+�+�F�4�L��
rc��|jjS�N)rr�rs rrzBaseElement.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��$)���!�!�!rc�4�|j���Sr()r�get_versionr)s r�versionzBaseElement.versionos����*�*�,�,�,rc��||_dSr()r)r�	parameters  r�
set_parameterzBaseElement.set_parameterss
��#����rNc�*�tj|��Sr()rr%r/s  rr%zBaseElement.next_idvs���~�e�$�$�$rc�f�d|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 r�get_idzBaseElement.get_idys2���t�|�#�#�!%�����D�L����|�D�!�!rc�0�d|���zS)zn
        Get the `IRI` reference string of the object. (i.e., ``'#id'``).

        :returns: `string`
        z#%s)r8r)s r�get_irizBaseElement.get_iri�s���t�{�{�}�}�$�$rc�0�d|���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_funciri�s���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� � rc�j�|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)rr-�check_svg_attribute_value�elementnamer)rr r!s   rrzBaseElement.__setitem__�s>���:�	S��N�4�4�T�5E�s�E�R�R�R�!���S���rc��|jr%|j�|j|j��|j�|��|S)z� Add an SVG element as subelement.

        :param element: append this SVG element
        :returns: the added element

        )rr-�check_valid_childrenrAr�append)r�elements  r�addzBaseElement.add�sH���:�	W��N�/�/��0@�'�BU�V�V�V��
���W�%�%�%��rc��|���}tj|d���}|�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�xml�xml_utf8_strs   rrJzBaseElement.tostring�s9���l�l�n�n���~�c�G�<�<�<���"�"�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���}�}���rc��tj|j��}|jr%|j�|j|j��t|j�����D]4\}}|�-|�	|��}|r|�
||���5|jD])}|�|�
�����*|S)z� Get the XML representation as `ElementTree` object.

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

        )r�ElementrArr-�check_all_svg_attribute_valuesr�sortedr�value_to_string�setrrDrI)rrL�	attributer!rEs     rrIzBaseElement.get_xml�s����m�D�,�-�-���:�	Z��N�9�9�$�:J�D�L�Y�Y�Y� &�t�|�'9�'9�';�';� <� <�	.�	.��I�u�� ��,�,�U�3�3���.��G�G�I�u�-�-�-���}�	*�	*�G��J�J�w���(�(�)�)�)�)��
rc��t|ttf��rR|jr|j�|d��t|t��r|jdkrt|d��}t|��S)z�
        Converts *value* into a <string> includes a value check, depending
        on :attr:`self.debug` and :attr:`self.profile`.

        �number�tiny�)	�
isinstance�int�floatrr-�check_svg_typer�round�strr/s  rrTzBaseElement.value_to_string�ss���e�c�5�\�*�*�	(��z�
?���-�-�e�X�>�>�>��%��'�'�
(�D�L�F�,B�,B��e�Q�����5�z�z�rc��|�(|j�dt|����|�*|j�dt|����dSdS)zK Insert a **title** and/or a **desc** element as first subelement.
        Nr)r�insert�Desc�Title)r�title�descs   r�set_desczBaseElement.set_desc�sZ�����M� � ��D��J�J�/�/�/����M� � ��E�%�L�L�1�1�1�1�1��rc��t|��}t|j��dkr|j�|��dSd}|j|jdvrM|dz
}|t|j��kr|j�|��dS|j|jdv�M|j|jdkr'|j|j�|��dS|j�||��dS)�N
        :param xmldata: an xml.etree.ElementTree - Element() object.
        r)rerf�N�metadata)�Metadata�lenrrDrArLrb)r�xmldatark�poss    r�set_metadatazBaseElement.set_metadata�s���G�$�$���t�}����"�"��M� � ��*�*�*�*�*��C��-��$�0�4E�E�E��q����#�d�m�,�,�,�,��M�(�(��2�2�2��F�	�-��$�0�4E�E�E�
�}�S�!�-��;�;��
�c�"�&�-�-�g�6�6�6�6�6��
�$�$�S�(�3�3�3�3�3rr()NN)�__name__�
__module__�__qualname__�__doc__rArrr$�propertyrrr-�setterr2r5r%r8r:r<r>rrFrJrOrIrTrgrp�rrrrs��������� �K�)�)�)�V
)�
)�
)�����%�%��X�%��'�'��X�'��)�)��X�)���*�*���*��-�-��X�-�$�$�$�%�%�%�%�"�"�"�%�%�%�*�*�*�!�!�!�"�"�"�
�
�
�	,�	,�	,�������(���2�2�2�2�4�4�4�4�4rrc��eZdZdZd�Zd�ZdS)rdrec�t�tj|j��|_t	|��|j_dSr()rrQrArLr`�text)rrzs  rrzTitle.__init__	s)���=��!1�2�2����D�	�	���
�
�
rc��|jSr()rLr)s rrIz
Title.get_xml
s	���x�rN)rqrrrsrArrIrwrrrdrds7�������K�"�"�"�����rrdc��eZdZdZdS)rcrfN)rqrrrsrArwrrrcrcs�������K�K�Krrcc��eZdZdZd�ZdS)rlrkc�l�tjd��|_|j�|��dS)rirkN)rrQrLrD)rrns  rrzMetadata.__init__s/���=��,�,�������� � � � � rN)rqrrrsrArrwrrrlrls(�������K�!�!�!�!�!rrl)
rt�svgwrite.etreerr$�svgwrite.paramsr�svgwrite.utilsr�objectrrdrcrlrwrr�<module>r�s����!� � � � � �����%�%�%�%�%�%�!�!�!�!�!�!�o4�o4�o4�o4�o4�&�o4�o4�o4�d�����F���������5����!�!�!�!�!�u�!�!�!�!�!r

Zerion Mini Shell 1.0