def fixup_internal_links(config, soups):
 reverse_directory = {}
 for (d, s) in config[u'sources'].items():
  reverse_directory[s] = d
 for (name, soup) in soups.items():
  old_src_dir = os.path.dirname(config[u'sources'][name])
  for tag in soup.find_all(True):
   if (not (u'href' in tag.attrs)):
    continue
   old_rel_path = tag[u'href'].split(u'#')[0]
   old_dst = os.path.normpath(os.path.join(old_src_dir, old_rel_path))
   if (not (old_dst in reverse_directory)):
    continue
   new_dst = (reverse_directory[old_dst] + u'.html')
   new_rel_path = rel_href(name, new_dst)
   tag[u'href'] = tag[u'href'].replace(old_rel_path, new_rel_path, 1)

def fixup_internal_links ( config , soups ) : reverse_directory = { } for ( d , s ) in config [ u'sources' ] . items ( ) : reverse_directory [ s ] = d for ( name , soup ) in soups . items ( ) : old_src_dir = os . path . dirname ( config [ u'sources' ] [ name ] ) for tag in soup . find_all ( True ) : if ( not ( u'href' in tag . attrs ) ) : continue old_rel_path = tag [ u'href' ] . split ( u'#' ) [ 0 ] old_dst = os . path . normpath ( os . path . join ( old_src_dir , old_rel_path ) ) if ( not ( old_dst in reverse_directory ) ) : continue new_dst = ( reverse_directory [ old_dst ] + u'.html' ) new_rel_path = rel_href ( name , new_dst ) tag [ u'href' ] = tag [ u'href' ] . replace ( old_rel_path , new_rel_path , 1 )
find href=" .