Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib/python2.7/site-packages/svgwrite
opt
/
alt
/
python27
/
lib
/
python2.7
/
site-packages
/
svgwrite
/
📁
..
📄
__init__.py
(2.39 KB)
📄
__init__.pyc
(3.15 KB)
📄
__init__.pyo
(3.15 KB)
📄
animate.py
(6.47 KB)
📄
animate.pyc
(7.61 KB)
📄
animate.pyo
(7.61 KB)
📄
base.py
(7.88 KB)
📄
base.pyc
(9.78 KB)
📄
base.pyo
(9.78 KB)
📄
container.py
(8.81 KB)
📄
container.pyc
(10.69 KB)
📄
container.pyo
(10.69 KB)
📁
data
📄
drawing.py
(4.24 KB)
📄
drawing.pyc
(4.82 KB)
📄
drawing.pyo
(4.82 KB)
📄
elementfactory.py
(2.15 KB)
📄
elementfactory.pyc
(2.89 KB)
📄
elementfactory.pyo
(2.89 KB)
📄
etree.py
(1.33 KB)
📄
etree.pyc
(1.27 KB)
📄
etree.pyo
(1.27 KB)
📄
filters.py
(7.71 KB)
📄
filters.pyc
(13.33 KB)
📄
filters.pyo
(13.33 KB)
📄
gradients.py
(4.61 KB)
📄
gradients.pyc
(5.89 KB)
📄
gradients.pyo
(5.89 KB)
📄
image.py
(2.39 KB)
📄
image.pyc
(2.95 KB)
📄
image.pyo
(2.95 KB)
📄
masking.py
(1.78 KB)
📄
masking.pyc
(2.24 KB)
📄
masking.pyo
(2.24 KB)
📄
mixins.py
(10.2 KB)
📄
mixins.pyc
(12.74 KB)
📄
mixins.pyo
(12.74 KB)
📄
params.py
(1.84 KB)
📄
params.pyc
(2.73 KB)
📄
params.pyo
(2.73 KB)
📄
path.py
(3.51 KB)
📄
path.pyc
(3.66 KB)
📄
path.pyo
(3.66 KB)
📄
pattern.py
(1.9 KB)
📄
pattern.pyc
(2.29 KB)
📄
pattern.pyo
(2.29 KB)
📄
shapes.py
(5.72 KB)
📄
shapes.pyc
(6.6 KB)
📄
shapes.pyo
(6.6 KB)
📄
text.py
(7.94 KB)
📄
text.pyc
(9.5 KB)
📄
text.pyo
(9.5 KB)
📄
utils.py
(6.07 KB)
📄
utils.pyc
(7.37 KB)
📄
utils.pyo
(7.37 KB)
📄
validator2.py
(5.93 KB)
📄
validator2.pyc
(6.95 KB)
📄
validator2.pyo
(6.95 KB)
Editing: validator2.py
#coding:utf-8 # Author: mozman --<mozman@gmx.at> # Purpose: validator2 module - new validator module # Created: 01.10.2010 # Copyright (C) 2010, Manfred Moitzi # License: MIT License from svgwrite.data import full11 from svgwrite.data import tiny12 from svgwrite.data import pattern validator_cache = {} def cache_key(profile, debug): return str(profile) + str(debug) def get_validator(profile, debug=True): """ Validator factory """ try: return validator_cache[cache_key(profile, debug)] except KeyError: if profile == 'tiny': validator = Tiny12Validator(debug) elif profile in ('full', 'basic', 'none'): validator = Full11Validator(debug) else: raise ValueError("Unsupported profile: '%s'" % profile) validator_cache[cache_key(profile, debug)] = validator return validator class Tiny12Validator(object): profilename = "Tiny 1.2" def __init__(self, debug=True): self.debug = debug self.attributes = tiny12.attributes self.elements = tiny12.elements self.typechecker = tiny12.TypeChecker() def check_all_svg_attribute_values(self, elementname, attributes): """ Check if attributes are valid for object 'elementname' and all svg attributes have valid types and values. Raises ValueError. """ for attributename, value in attributes.items(): self.check_svg_attribute_value(elementname, attributename, value) def check_svg_attribute_value(self, elementname, attributename, value): """ Check if 'attributename' is valid for object 'elementname' and 'value' is a valid svg type and value. Raises ValueError. """ self._check_valid_svg_attribute_name(elementname, attributename) self._check_svg_value(elementname, attributename, value) def _check_svg_value(self, elementname, attributename, value): """ Checks if 'value' is a valid svg-type for svg-attribute 'attributename' at svg-element 'elementname'. Raises TypeError. """ attribute = self.attributes[attributename] # check if 'value' match a valid datatype for typename in attribute.get_types(elementname): if self.typechecker.check(typename, value): return # check if 'value' is a valid constant valuestr = str(value) if not valuestr in attribute.get_const(elementname): raise TypeError("'%s' is not a valid value for attribute '%s' at svg-element <%s>." % (value, attributename, elementname)) def _check_valid_svg_attribute_name(self, elementname, attributename): """ Check if 'attributename' is a valid svg-attribute for svg-element 'elementname'. Raises ValueError. """ if not self.is_valid_svg_attribute(elementname, attributename): raise ValueError("Invalid attribute '%s' for svg-element <%s>." % (attributename, elementname)) def _get_element(self, elementname): try: return self.elements[elementname] except KeyError: raise KeyError("<%s> is not valid for selected profile: '%s'." % (elementname, self.profilename)) def check_svg_type(self, value, typename='string'): """ Check if 'value' matches svg type 'typename'. Raises TypeError. """ if self.typechecker.check(typename, value): return value else: raise TypeError("%s is not of type '%s'." % (value, typename)) def is_valid_elementname(self, elementname): """ True if 'elementname' is a valid svg-element name. """ return elementname in self.elements def is_valid_svg_attribute(self, elementname, attributename): """ True if 'attributename' is a valid svg-attribute for svg-element 'elementname'. """ element = self._get_element(elementname) return attributename in element.valid_attributes def is_valid_children(self, elementname, childrenname): """ True if svg-element 'childrenname' is a valid children of svg-element 'elementname'. """ element = self._get_element(elementname) return childrenname in element.valid_children def check_valid_children(self, elementname, childrenname): """ Checks if svg-element 'childrenname' is a valid children of svg-element 'elementname'. Raises ValueError. """ if not self.is_valid_children(elementname, childrenname): raise ValueError("Invalid children '%s' for svg-element <%s>." % (childrenname, elementname)) def get_coordinate(self, value): """ Split value in (number, unit) if value has an unit or (number, None). Raises ValueError. """ if value is None: raise TypeError("Invalid type 'None'.") if isinstance(value, (int, float)): result = (value, None) else: result = pattern.coordinate.match(value.strip()) if result: number, tmp, unit = result.groups() number = float(number) else: raise ValueError("'%s' is not a valid svg-coordinate." % value) result = (number, unit) if self.typechecker.is_number(result[0]): return result else: version = "SVG %s %s" % self.typechecker.get_version() raise ValueError("%s is not a valid number for: %s." % (value, version)) get_length = get_coordinate class Full11Validator(Tiny12Validator): profilename = "Full 1.1" def __init__(self, debug=True): self.debug = debug self.attributes = full11.attributes self.elements = full11.elements self.typechecker = full11.TypeChecker()
Upload File
Create Folder