ok

Mini Shell

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

�

�܋f����dZddlZddlmZddlmZd�Zdd�Zd�Zdd
�Z	d�Z
d�Zd
�Zd d�Z
Gd�de��Zd!d�Zddddddd�Zd�Zd�Zd�ZdS)"z�

.. autofunction:: rgb

.. autofunction:: iterflatlist

.. autofunction:: strlist

.. autofunction:: get_unit

.. autofunction:: split_coordinate

.. autofunction:: split_angle

.. autofunction:: rect_top_left_corner

.. autofunction:: pretty_xml

�N)�Path)�patternc�,�t|t��S�N)�
isinstance�str��values �E/opt/cloudlinux/venv/lib64/python3.11/site-packages/svgwrite/utils.py�	is_stringr s���e�S�!�!�!��RGBc��d�}|���dkr8dt|��dzt|��dzt|��dzfzS|dkr#d||��||��||��fzStd|z���)aM
    Convert **r**, **g**, **b** values to a `string`.

    :param r: red part
    :param g: green part
    :param b: blue part
    :param string mode: ``'RGB | %'``

    :rtype: string

    ========= =============================================================
    mode      Description
    ========= =============================================================
    ``'RGB'`` returns a rgb-string format: ``'rgb(r, g, b)'``
    ``'%'``   returns percent-values as rgb-string format: ``'rgb(r%, g%, b%)'``
    ========= =============================================================

    c�D�t|��}|dkrd}|dkrd}|S)Nr�d)�floatr	s r�percentzrgb.<locals>.percent8s.���e�����1�9�9��E��3�;�;��E��r
rz
rgb(%d,%d,%d)��%zrgb(%d%%,%d%%,%d%%)zInvalid mode '%s')�upper�int�
ValueError)�r�g�b�moders     r�rgbr$s���(����z�z�|�|�u����#�a�&�&�3�,��A�����c�!�f�f�s�l�!K�K�K�	
����%����
�
�G�G�A�J�J����
�
�'K�K�K��,�t�3�4�4�4r
c#�K�|D]<}t|d��r&t|��st|��D]}|V���8|V��=dS)z:
    Flatten nested *values*, returns an `iterator`.

    �__iter__N)�hasattrr�iterflatlist)�values�element�items   rr!r!Jsv����
�����7�J�'�'�	�	�'�0B�0B�	�$�W�-�-�
�
���
�
�
�
�
��M�M�M�M��r
�,c�|�t|��r|S|�d�t|��D����S)z�
    Concatenate **values** with **sepertator**, `None` values will be excluded.

    :param values: `iterable` object
    :returns: `string`

    c�0�g|]}|�t|����Sr)r)�.0r
s  r�
<listcomp>zstrlist.<locals>.<listcomp>bs#��a�a�a�e�u�O`�s�5�z�z�O`�O`�O`r
)r�joinr!)r"�	seperators  r�strlistr,WsC������c��
��~�~�a�a�|�F�7K�7K�a�a�a�b�b�br
c���t|ttf��rdStj�|��}|r|�d��Std|z���)z�
    Get the `unit` identifier of **coordinate**, if **coordinate** has a valid
    `unit` identifier appended, else returns `None`.

    N��Invalid format: '%s'�rrrr�
coordinate�match�groupr�r1�results  r�get_unitr6esa���*�s�E�l�+�+���t�
�
�
%�
%�j�
1�
1�F�
�>��|�|�A�����/�*�<�=�=�=r
c�0�t|ttf��rt|��dfStj�|��}|r7t|�d����|�d��fStd|z���)z�
    Split coordinate into `<number>` and 'unit` identifier.

    :returns: <2-tuple> (number, unit-identifier) or (number, None) if no unit-identifier
      is present or coordinate is an int or float.

    N�r.r/r0r4s  r�split_coordinater9ts����*�s�E�l�+�+�)��j�!�!�4�(�(�
�
�
%�
%�j�
1�
1�F�
�>��f�l�l�1�o�o�&�&����Q���8�8��/�*�<�=�=�=r
c�0�t|ttf��rt|��dfStj�|��}|r7t|�d����|�d��fStd|z���)z�
    Split angle into `<number>` and `<angle>` identifier.

    :returns: <2-tuple> (number, angle-identifier) or (number, None) if no angle-identifier
      is present or angle is an int or float.

    Nr8r.r/)rrrr�angler2r3r)r;r5s  r�split_angler<�s����%�#�u��&�&�$��e���d�#�#�
�]�
 �
 ��
'�
'�F�
�9��f�l�l�1�o�o�&�&����Q���8�8��/�%�7�8�8�8r
�top-leftc�^�|����d��\}}t|d��\}}t|d��\}}t|d��\}	}
t|d��\}}||
krtd���||krtd���|dkr	||	dzz
}n$|dkr||	z
}n|d	krtd
|z���|dkr	||dzz
}n$|dkr||z
}n|d
krtd|z���|r|�|��}|r|�|��}||fS)a4
    Calculate top-left corner of a rectangle.

    **insert** and **size** must have the same units.

    :param 2-tuple insert: insert point
    :param 2-tuple size: (width, height)
    :param string pos: insert position ``'vert-horiz'``
    :return: ``'top-left'`` corner of the rect
    :rtype: 2-tuple

    ========== ==============================
    pos        valid values
    ========== ==============================
    **vert**   ``'top | middle | bottom'``
    **horiz**  ``'left'|'center'|'right'``
    ========== ==============================
    �-rr8z0x-coordinate and width has to have the same unitz1y-coordinate and height has to have the same unit�centerg@�right�leftz!Invalid horizontal position: '%s'�middle�bottom�topzInvalid vertical position: '%s')�lower�splitr9r)
�insert�size�pos�vert�horiz�x�xunit�y�yunit�width�wunit�height�hunits
             r�rect_top_left_cornerrU�sv��&�)�)�+�+�#�#�C�(�(�K�D�%���q�	�*�*�H�A�u���q�	�*�*�H�A�u�#�D��G�,�,�L�E�5�$�T�!�W�-�-�M�F�E���~�~��K�L�L�L���~�~��L�M�M�M�����
���
�N���	�'�	�	�
��I���	�&����<�u�D�E�E�E��x���
����O���	
��	�	�
��J���	
�����:�T�A�B�B�B�� ��a������ ��a������a�4�Kr
c�J�eZdZdZdd�Zedd���Zedd���ZdS)�AutoIDr8Nc�0�|�|��dSr)�
_set_value)�selfr
s  r�__init__zAutoID.__init__�s����������r
c��|�	||_dSdSr)�_nextid)�clsr
s  rrYzAutoID._set_value�s�����C�K�K�K��r
c�d�|�|��d|jz}|xjdz
c_|S)Nzid%dr8)rYr])r^r
�retvals   r�next_idzAutoID.next_id�s5�����u�����#�+�%�����q�����
r
r)�__name__�
__module__�__qualname__r]r[�classmethodrYra�r
rrWrW�sm�������G������ � � ��[� ������[���r
rW�c�*�ddlmcm}t|��dkr|���dkrdS|�|��}|�d|z����d��}d�|dd���S)	z�
    Create human readable XML string.

    :param xml_string: input xml string without line breaks and indentation
    :indent int: how much to indent, by default 2 spaces
    :return: xml_string with linebreaks and indentation

    rN��� )�indent�
r8)	�xml.dom.minidom�dom�minidom�len�strip�parseString�toprettyxmlrGr*)�
xml_stringrlrp�xml_tree�liness     r�
pretty_xmlrx�s���&�%�%�%�%�%�%�%�%��:������
� 0� 0� 2� 2�b� 8� 8��r��"�"�:�.�.�H�� � ��f�� �5�5�;�;�D�A�A�E��9�9�U�1�2�2�Y���r
zapplication/x-font-ttfzapplication/x-font-opentypezapplication/font-woffzapplication/font-woff2zapplication/vnd.ms-fontobjectzapplication/font-sfnt)�ttf�otf�woff�woff2�eot�sfntc�t�tt|�����jdd�S)Nr8)�FONT_MIMETYPESrrF�suffix)�names r�
font_mimetyper��s)���$�t�z�z�|�|�,�,�3�A�B�B�7�8�8r
c�|�tj|�����}d�||���S)Nz+data:{mimetype};charset=utf-8;base64,{data})�mimetype�data)�base64�	b64encode�decode�format)r�r�s  r�base64_datar��s8����D�!�!�(�(�*�*�D�8�?�?��X\�?�]�]�]r
c�N�ddl}|�d|��}|r|dSdS)Nrzurl\((.*?)\))�re�findall)�textr�r5s   r�find_first_urlr�s5��
�I�I�I�
�Z�Z���
.�
.�F�
���a�y���tr
)rrrr)r%)r=)rg)�__doc__r��pathlibr�
svgwrite.datarrrr!r,r6r9r<rU�objectrWrxr�r�r�r�rfr
r�<module>r�sc����&�
�
�
�������!�!�!�!�!�!�"�"�"�#5�#5�#5�#5�L
�
�
�c�c�c�c�>�>�>�>�>�>�"9�9�9�$0�0�0�0�f�����V����& � � � �*$�(�#�
%�*�#�
���9�9�9�^�^�^�
����r

Zerion Mini Shell 1.0