How to use the scour.yocto_css.parseCssString 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 / test_css.py View on Github external
def runTest(self):
        r = parseCssString('foo { bar: baz}')
        self.assertEqual(len(r), 1, 'Element selector not returned')
        self.assertEqual(r[0]['selector'], 'foo', 'Selector for foo not returned')
        self.assertEqual(len(r[0]['properties']), 1, 'Property list for foo did not have 1')
        self.assertEqual(r[0]['properties']['bar'], 'baz', 'Property bar did not have baz value')
github scour-project / scour / test_css.py View on Github external
def runTest(self):
        r = parseCssString('foo {}')
        self.assertEqual(len(r), 1, 'Element selector not returned')
        self.assertEqual(r[0]['selector'], 'foo', 'Selector for foo not returned')
        self.assertEqual(len(r[0]['properties']), 0, 'Property list for foo not empty')
github scour-project / scour / test_css.py View on Github external
def runTest(self):
        r = parseCssString('')
        self.assertEqual(len(r), 0, 'Blank string returned non-empty list')
        self.assertEqual(type(r), type([]), 'Blank string returned non list')
github scour-project / scour / scour / scour.py View on Github external
xlink:href attributes.
   """
   global referencingProps
   if ids is None:
      ids = {}
   # TODO: input argument ids is clunky here (see below how it is called)
   # GZ: alternative to passing dict, use **kwargs

   # if this node is a style element, parse its text into CSS
   if node.nodeName == 'style' and node.namespaceURI == NS['SVG']:
      # one stretch of text, please! (we could use node.normalize(), but
      # this actually modifies the node, and we don't want to keep
      # whitespace around if there's any)
      stylesheet = "".join([child.nodeValue for child in node.childNodes])
      if stylesheet != '':
         cssRules = parseCssString(stylesheet)
         for rule in cssRules:
            for propname in rule['properties']:
               propval = rule['properties'][propname]
               findReferencingProperty(node, propname, propval, ids)
      return ids

   # else if xlink:href is set, then grab the id
   href = node.getAttributeNS(NS['XLINK'],'href')
   if href != '' and len(href) > 1 and href[0] == '#':
      # we remove the hash mark from the beginning of the id
      id = href[1:]
      if id in ids:
         ids[id][0] += 1
         ids[id][1].append(node)
      else:
         ids[id] = [1,[node]]