def link_pantsrefs(soups, precomputed):
 for (page, soup) in soups.items():
  for a in soup.find_all(u'a'):
   if a.has_attr(u'pantsref'):
    pantsref = a[u'pantsref']
    if (not (pantsref in precomputed.pantsref)):
     raise TaskError(u'Page {0} has pantsref "{1}" and I cannot find pantsmark for it'.format(page, pantsref))
    a[u'href'] = rel_href(page, precomputed.pantsref[pantsref])

def link_pantsrefs ( soups , precomputed ) : for ( page , soup ) in soups . items ( ) : for a in soup . find_all ( u'a' ) : if a . has_attr ( u'pantsref' ) : pantsref = a [ u'pantsref' ] if ( not ( pantsref in precomputed . pantsref ) ) : raise TaskError ( u'Page {0} has pantsref "{1}" and I cannot find pantsmark for it' . format ( page , pantsref ) ) a [ u'href' ] = rel_href ( page , precomputed . pantsref [ pantsref ] )
transorm soups: <a pantsref="foo"> becomes <a href=" .