%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/svgwrite/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyo

�
J^oRc@s�dZddlZejddkZddlmZerJeZeZn	d�Zd�Z	ddl
mZdddd	d
�Zd�Z
dd
�Zd�Zd�Zd�Zdd�Zdefd��YZdS(s�

.. autofunction:: rgb

.. autofunction:: iterflatlist

.. autofunction:: strlist

.. autofunction:: get_unit

.. autofunction:: split_coordinate

.. autofunction:: split_angle

.. autofunction:: rect_top_left_corner

i����Nii(tpartialcCs)t|t�rt|dd�St|�S(Ntencodingtutf8(t
isinstancetstrtunicode(tvalue((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyt
to_unicode"scCs
t|t�S(N(Rt
basestring(R((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyt	is_string's(tpatterntRGBcCs�d�}|j�dkrJdt|�d@t|�d@t|�d@fS|dkryd||�||�||�fStd|��dS(	sM
    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%)'``
    ========= =============================================================

    cSs:t|�}|dkr!d}n|dkr6d}n|S(Niid(tint(R((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytpercent@s		Rs
rgb(%d,%d,%d)i�t%srgb(%d%%,%d%%,%d%%)sInvalid mode '%s'N(tupperRt
ValueError(trtgtbtmodeR
((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytrgb-s	/#ccsUxN|D]F}t|d�rHt|�rHx!t|�D]}|Vq6Wq|VqWdS(s:
    Flatten nested *values*, returns an `iterator`.

    t__iter__N(thasattrR	titerflatlist(tvaluestelementtitem((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyRQs

t,cCsLt|�r|S|jgt|�D]}|dk	r#t|�^q#�SdS(s�
    Concatenate **values** with **sepertator**, `None` values will be excluded.

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

    N(R	tjoinRtNoneR(Rt	seperatorR((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytstrlist]scCsRt|ttf�rdStjj|�}|r>|jd�Std|��dS(s�
    Get the `unit` identifier of **coordinate**, if **coordinate** has a valid
    `unit` identifier appended, else returns `None`.

    isInvalid format: '%s'N(	RRtfloatRR
t
coordinatetmatchtgroupR(R"tresult((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytget_unitjs
cCsst|ttf�r%t|�dfStjj|�}|r_t|jd��|jd�fStd|��dS(s�
    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.

    iisInvalid format: '%s'N(	RRR!RR
R"R#R$R(R"R%((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytsplit_coordinatexs"cCsst|ttf�r%t|�dfStjj|�}|r_t|jd��|jd�fStd|��dS(s�
    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.

    iisInvalid format: '%s'N(	RRR!RR
tangleR#R$R(R(R%((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytsplit_angle�s	"stop-leftc
Cs�|j�jd�\}}t|d�\}}t|d�\}}t|d�\}	}
t|d�\}}||
kr�td��n||kr�td��n|dkr�||	d}n8|dkr�||	}n|d	kr�td
|��n|dkr||d}n8|dkr4||}n|d
krStd|��n|rld||f}n|r�d||f}n||fS(s4
    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'``
    ========== ==============================
    t-iis0x-coordinate and width has to have the same units1y-coordinate and height has to have the same unittcenterg@trighttlefts!Invalid horizontal position: '%s'tmiddletbottomttopsInvalid vertical position: '%s's%s%s(tlowertsplitR'R(
tinserttsizetpostvertthoriztxtxunittytyunittwidthtwunittheightthunit((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytrect_top_left_corner�s4

tAutoIDcBs>eZdZdd�Zedd��Zedd��ZRS(icCs|j|�dS(N(t
_set_value(tselfR((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyt__init__�scCs|dk	r||_ndS(N(Rt_nextid(tclsR((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyRB�scCs-|j|�d|j}|jd7_|S(Nsid%di(RBRE(RFRtretval((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pytnext_id�s

N(t__name__t
__module__RERRDtclassmethodRBRH(((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyRA�s(t__doc__tsystversion_infotPYTHON3t	functoolsRRRRR	t
svgwrite.dataR
RRR R&R'R)R@tobjectRA(((s?/opt/alt/python27/lib/python2.7/site-packages/svgwrite/utils.pyt<module>s"			$	
			2

Zerion Mini Shell 1.0