How to use the scour.scour.Unit.NONE function in scour

To help you get started, we’ve selected a few scour examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scour-project / scour / scour / scour.py View on Github external
if node.nodeName in ['circle', 'ellipse']:
         if cy.value == 0:
            node.removeAttribute('cy')
            num += 1
      elif node.nodeName == "radialGradient":
         if ( (cy.value == 50  and cy.units == Unit.PCT) or
              (cy.value == 0.5 and cy.units == Unit.NONE and not node.getAttribute('gradientUnits') == 'userSpaceOnUse') ):
            node.removeAttribute('cy')
            num += 1

   # r - radialGradient: 50% (r="0.5" usually equals "0.5px" which only equals "50%" if gradientUnits="objectBoundingBox")
   if node.getAttribute('r') != '':
      if node.nodeName == 'radialGradient':
         r = SVGLength(node.getAttribute('r'))
         if ( (r.value == 50  and r.units == Unit.PCT) or
              (r.value == 0.5 and r.units == Unit.NONE and not node.getAttribute('gradientUnits') == 'userSpaceOnUse') ):
            node.removeAttribute('r')
            num += 1

   # Summarily get rid of some more attributes
   attributes = [node.attributes.item(i).nodeName
              for i in range(node.attributes.length)]
   for attribute in attributes:
      if attribute not in tainted:
         if attribute in list(default_attributes.keys()):
            if node.getAttribute(attribute) == default_attributes[attribute]:
               node.removeAttribute(attribute)
               num += 1
            else:
               tainted = taint(tainted, attribute)
   # These attributes might also occur as styles
   styles = _getStyle(node)
github scour-project / scour / scour / scour.py View on Github external
def __init__(self, str):
      try: # simple unitless and no scientific notation
         self.value = float(str)
         if int(self.value) == self.value:
            self.value = int(self.value)
         self.units = Unit.NONE
      except ValueError:
         # we know that the length string has an exponent, a unit, both or is invalid

         # parse out number, exponent and unit
         self.value = 0
         unitBegin = 0
         scinum = scinumber.match(str)
         if scinum != None:
            # this will always match, no need to check it
            numMatch = number.match(str)
            expMatch = sciExponent.search(str, numMatch.start(0))
            self.value = (float(numMatch.group(0)) *
               10 ** float(expMatch.group(1)))
            unitBegin = expMatch.end(1)
         else:
            # unit or invalid
github scour-project / scour / scour / scour.py View on Github external
def get(unitstr):
      if unitstr is None: return Unit.NONE
      try:
         return Unit.s2u[unitstr]
      except KeyError:
         return Unit.INVALID