def _extract_sel_info(sel):
    """Recurse down parsed tree, return pseudo class info"""
    from cssselect2.parser import (CombinedSelector, CompoundSelector,
                                   PseudoClassSelector,
                                   FunctionalPseudoClassSelector)
    steps = []
    extras = []
    if isinstance(sel, CombinedSelector):
        lstep, lextras = _extract_sel_info(sel.left)
        rstep, rextras = _extract_sel_info(sel.right)
        steps = lstep + rstep
        extras = lextras + rextras
    elif isinstance(sel, CompoundSelector):
        for ssel in sel.simple_selectors:
            s, e = _extract_sel_info(ssel)
            steps.extend(s)
            extras.extend(e)
    elif isinstance(sel, FunctionalPseudoClassSelector):
        if sel.name == 'pass':
            steps.append(serialize(sel.arguments).strip('"\''))
    elif isinstance(sel, PseudoClassSelector):
        if sel.name == 'deferred':
            extras.append('deferred')
    return (steps, extras)
def _extract_sel_info ( sel ) : from cssselect2 . parser import ( CombinedSelector , CompoundSelector , PseudoClassSelector , FunctionalPseudoClassSelector ) steps = [ ] extras = [ ] if isinstance ( sel , CombinedSelector ) : lstep , lextras = _extract_sel_info ( sel . left ) rstep , rextras = _extract_sel_info ( sel . right ) steps = lstep + rstep extras = lextras + rextras elif isinstance ( sel , CompoundSelector ) : for ssel in sel . simple_selectors : s , e = _extract_sel_info ( ssel ) steps . extend ( s ) extras . extend ( e ) elif isinstance ( sel , FunctionalPseudoClassSelector ) : if sel . name == 'pass' : steps . append ( serialize ( sel . arguments ) . strip ( '"\'' ) ) elif isinstance ( sel , PseudoClassSelector ) : if sel . name == 'deferred' : extras . append ( 'deferred' ) return ( steps , extras )
Recurse down parsed tree, return pseudo class info