def _refsToReplace(value, modFunct, titlesRefs, namesRefs, charactersRefs):
 mRefs = []
 for (refRe, refTemplate) in [(re_titleRef, u'_%s_ (qv)'), (re_nameRef, u"'%s' (qv)"), (re_characterRef, u'#%s# (qv)')]:
  theseRefs = []
  for theRef in refRe.findall(value):
   goodValue = modFunct((refTemplate % theRef), titlesRefs, namesRefs, charactersRefs)
   if (('_' in goodValue) or (len(goodValue) > 128)):
    continue
   toReplace = escape4xml(goodValue)
   replaceWith = goodValue.replace(theRef, escape4xml(theRef))
   theseRefs.append((toReplace, replaceWith))
  mRefs.append(theseRefs)
 return mRefs

def _refsToReplace ( value , modFunct , titlesRefs , namesRefs , charactersRefs ) : mRefs = [ ] for ( refRe , refTemplate ) in [ ( re_titleRef , u'_%s_ (qv)' ) , ( re_nameRef , u"'%s' (qv)" ) , ( re_characterRef , u'#%s# (qv)' ) ] : theseRefs = [ ] for theRef in refRe . findall ( value ) : goodValue = modFunct ( ( refTemplate % theRef ) , titlesRefs , namesRefs , charactersRefs ) if ( ( '_' in goodValue ) or ( len ( goodValue ) > 128 ) ) : continue toReplace = escape4xml ( goodValue ) replaceWith = goodValue . replace ( theRef , escape4xml ( theRef ) ) theseRefs . append ( ( toReplace , replaceWith ) ) mRefs . append ( theseRefs ) return mRefs
return three lists - for movie titles .