Esempio n. 1
0
 def repr_parse(css):
     selectors = parse(css)
     for selector in selectors:
         assert selector.pseudo_element is None
     return [
         repr(selector.parsed_tree).replace("(u'", "('")
         for selector in selectors
     ]
Esempio n. 2
0
 def parse_pseudo(css):
     result = []
     for selector in parse(css):
         pseudo = selector.pseudo_element
         pseudo = type('')(pseudo) if pseudo else pseudo
         # No Symbol here
         assert pseudo is None or isinstance(pseudo, type(''))
         selector = repr(selector.parsed_tree).replace("(u'", "('")
         result.append((selector, pseudo))
     return result
Esempio n. 3
0
 def get_error(css):
     try:
         parse(css)
     except SelectorSyntaxError:
         # Py2, Py3, ...
         return str(sys.exc_info()[1]).replace("(u'", "('")
Esempio n. 4
0
 def specificity(css):
     selectors = parse(css)
     assert len(selectors) == 1
     return selectors[0].specificity()