def fixLinks(document, ext):
 supported_schemes = ['http', 'https', 'ftp', 'mailto']
 for node in domhelpers.findElementsWithAttribute(document, 'href'):
  href = node.getAttribute('href')
  if (urlparse.urlparse(href)[0] in supported_schemes):
   continue
  if (node.getAttribute('class') == 'absolute'):
   continue
  if (node.getAttribute('class').find('listing') != (-1)):
   continue
  if (href.endswith('html') or href[:href.rfind('#')].endswith('html')):
   (fname, fext) = os.path.splitext(href)
   if ('#' in fext):
    fext = ((ext + '#') + fext.split('#', 1)[1])
   else:
    fext = ext
   node.setAttribute('href', (fname + fext))

def fixLinks ( document , ext ) : supported_schemes = [ 'http' , 'https' , 'ftp' , 'mailto' ] for node in domhelpers . findElementsWithAttribute ( document , 'href' ) : href = node . getAttribute ( 'href' ) if ( urlparse . urlparse ( href ) [ 0 ] in supported_schemes ) : continue if ( node . getAttribute ( 'class' ) == 'absolute' ) : continue if ( node . getAttribute ( 'class' ) . find ( 'listing' ) != ( - 1 ) ) : continue if ( href . endswith ( 'html' ) or href [ : href . rfind ( '#' ) ] . endswith ( 'html' ) ) : ( fname , fext ) = os . path . splitext ( href ) if ( '#' in fext ) : fext = ( ( ext + '#' ) + fext . split ( '#' , 1 ) [ 1 ] ) else : fext = ext node . setAttribute ( 'href' , ( fname + fext ) )
rewrite links to xhtml lore input documents so they point to lore xhtml output documents .