def fixRelativeLinks(document, linkrel):
 for attr in ('src', 'href'):
  for node in domhelpers.findElementsWithAttribute(document, attr):
   href = node.getAttribute(attr)
   if ((not href.startswith('http')) and (not href.startswith('/'))):
    node.setAttribute(attr, (linkrel + node.getAttribute(attr)))

def fixRelativeLinks ( document , linkrel ) : for attr in ( 'src' , 'href' ) : for node in domhelpers . findElementsWithAttribute ( document , attr ) : href = node . getAttribute ( attr ) if ( ( not href . startswith ( 'http' ) ) and ( not href . startswith ( '/' ) ) ) : node . setAttribute ( attr , ( linkrel + node . getAttribute ( attr ) ) )
replace relative links in c{str} and c{href} attributes with links relative to c{linkrel} .