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__/validator2.cpython-37.pyc

B

s�]}�@s^ddlmZddlmZddlmZiZdd�Zddd�ZGd	d
�d
e�ZGdd�de�Z	d
S)�)�full11)�tiny12)�patterncCst|�t|�S)N)�str)�profile�debug�r�/validator2.py�	cache_keysr
TcCsfytt||�Stk
r`|dkr0t|�}n|dkrBt|�}ntd|��|tt||�<|SXdS)z Validator factory Ztiny)ZfullZbasicZnonezUnsupported profile: '%s'N)�validator_cacher
�KeyError�Tiny12Validator�Full11Validator�
ValueError)rrZ	validatorrrr	�
get_validators

rc@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	d dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZeZdS)!r
zTiny 1.2TcCs$||_tj|_tj|_t��|_dS)N)rr�
attributes�elements�TypeChecker�typechecker)�selfrrrr	�__init__%szTiny12Validator.__init__cCs(x"|��D]\}}|�|||�q
WdS)z�
        Check if attributes are valid for object 'elementname' and all svg
        attributes have valid types and values.

        Raises ValueError.
        N)�items�check_svg_attribute_value)r�elementnamer�
attributename�valuerrr	�check_all_svg_attribute_values+sz.Tiny12Validator.check_all_svg_attribute_valuescCs|�||�|�|||�dS)z�
        Check if 'attributename' is valid for object 'elementname' and 'value'
        is a valid svg type and value.

        Raises ValueError.
        N)�_check_valid_svg_attribute_name�_check_svg_value)rrrrrrr	r5sz)Tiny12Validator.check_svg_attribute_valuecCs\|j|}x$|�|�D]}|j�||�rdSqWt|�}||�|�krXtd|||f��dS)z�
        Checks if 'value' is a valid svg-type for svg-attribute
        'attributename' at svg-element 'elementname'.

        Raises TypeError.
        NzA'%s' is not a valid value for attribute '%s' at svg-element <%s>.)rZ	get_typesr�checkrZ	get_const�	TypeError)rrrrZ	attribute�typename�valuestrrrr	r?s
z Tiny12Validator._check_svg_valuecCs |�||�std||f��dS)z~ Check if 'attributename' is a valid svg-attribute for svg-element
        'elementname'.

        Raises ValueError.
        z,Invalid attribute '%s' for svg-element <%s>.N)�is_valid_svg_attributer)rrrrrr	rPsz/Tiny12Validator._check_valid_svg_attribute_namecCs6y
|j|Stk
r0td||jf��YnXdS)Nz-<%s> is not valid for selected profile: '%s'.)rr�profilename)rrrrr	�_get_elementYs
zTiny12Validator._get_element�stringcCs&|j�||�r|Std||f��dS)zZ
        Check if 'value' matches svg type 'typename'.

        Raises TypeError.
        z%s is not of type '%s'.N)rrr )rrr!rrr	�check_svg_type_szTiny12Validator.check_svg_typecCs|j�||�S)N)rr)rrr!rrr	�is_valid_svg_typejsz!Tiny12Validator.is_valid_svg_typecCs
||jkS)z4 True if 'elementname' is a valid svg-element name. )r)rrrrr	�is_valid_elementnamemsz$Tiny12Validator.is_valid_elementnamecCs|�|�}||jkS)za True if 'attributename' is a valid svg-attribute for svg-element
        'elementname'.
        )r%Zvalid_attributes)rrr�elementrrr	r#qs
z&Tiny12Validator.is_valid_svg_attributecCs|�|�}||jkS)zf True if svg-element 'childrenname' is a valid children of
        svg-element 'elementname'.
        )r%Zvalid_children)rr�childrennamer*rrr	�is_valid_childrenxs
z!Tiny12Validator.is_valid_childrencCs |�||�std||f��dS)z� Checks if svg-element 'childrenname' is a valid children of
        svg-element 'elementname'.

        Raises ValueError.
        z+Invalid children '%s' for svg-element <%s>.N)r,r)rrr+rrr	�check_valid_childrensz$Tiny12Validator.check_valid_childrencCs�|dkrtd��t|ttf�r(|df}n@tj�|���}|rT|��\}}}t|�}nt	d|��||f}|j
�|d�r||Sd|j
��}t	d||f��dS)zk Split value in (number, unit) if value has an unit or (number, None).

        Raises ValueError.
        NzInvalid type 'None'.z#'%s' is not a valid svg-coordinate.rz	SVG %s %sz!%s is not a valid number for: %s.)
r �
isinstance�int�floatrZ
coordinate�match�strip�groupsrrZ	is_numberZget_version)rr�resultZnumberZtmpZunit�versionrrr	�get_coordinate�s

zTiny12Validator.get_coordinateN)T)r&)�__name__�
__module__�__qualname__r$rrrrrr%r'r(r)r#r,r-r6Z
get_lengthrrrr	r
"s


	
	r
c@seZdZdZddd�ZdS)rzFull 1.1TcCs$||_tj|_tj|_t��|_dS)N)rrrrrr)rrrrr	r�szFull11Validator.__init__N)T)r7r8r9r$rrrrr	r�srN)T)
Z
svgwrite.datarrrrr
r�objectr
rrrrr	�<module>s


Zerion Mini Shell 1.0