def souptest_sniff_node(node):
 if (node.tag is lxml.etree.Comment):
  if (node.text.strip() not in {'SC_ON', 'SC_OFF'}):
   raise SoupUnexpectedCommentError(node)
 elif isinstance(node.tag, basestring):
  tag_name = node.tag
  if (tag_name not in allowed_tags):
   raise SoupUnsupportedTagError(tag_name)
  for (attr, val) in node.items():
   if (attr not in allowed_tags[tag_name]):
    raise SoupUnsupportedAttrError(attr)
   if ((tag_name == 'a') and (attr == 'href')):
    lv = val.lower()
    if (not lv.startswith(valid_link_schemes)):
     raise SoupUnsupportedSchemeError(val)
    parsed_url = urlparse.urlparse(lv)
    if (parsed_url.hostname and (len(parsed_url.hostname) > 255)):
     raise SoupDetectedCrasherError(parsed_url.hostname)
    if ('%00' in urllib.unquote(parsed_url.path)):
     raise SoupDetectedCrasherError(lv)
 else:
  raise SoupUnsupportedNodeError(node)

def souptest_sniff_node ( node ) : if ( node . tag is lxml . etree . Comment ) : if ( node . text . strip ( ) not in { 'SC_ON' , 'SC_OFF' } ) : raise SoupUnexpectedCommentError ( node ) elif isinstance ( node . tag , basestring ) : tag_name = node . tag if ( tag_name not in allowed_tags ) : raise SoupUnsupportedTagError ( tag_name ) for ( attr , val ) in node . items ( ) : if ( attr not in allowed_tags [ tag_name ] ) : raise SoupUnsupportedAttrError ( attr ) if ( ( tag_name == 'a' ) and ( attr == 'href' ) ) : lv = val . lower ( ) if ( not lv . startswith ( valid_link_schemes ) ) : raise SoupUnsupportedSchemeError ( val ) parsed_url = urlparse . urlparse ( lv ) if ( parsed_url . hostname and ( len ( parsed_url . hostname ) > 255 ) ) : raise SoupDetectedCrasherError ( parsed_url . hostname ) if ( '%00' in urllib . unquote ( parsed_url . path ) ) : raise SoupDetectedCrasherError ( lv ) else : raise SoupUnsupportedNodeError ( node )
check that a node from an (x)html document passes the sniff test .