code: def build_import_pattern(mapping1, mapping2):
      u
      # py3k: urllib.request, py2k: ('urllib2', 'urllib')
      yield from_import % (all_modules_subpattern())
      for py3k, py2k in mapping1.items():
          name, attr = py3k.split(u'.')
          s_name = simple_name % (name)
          s_attr = simple_attr % (attr)
          d_name = dotted_name % (s_name, s_attr)
          yield name_import % (d_name)
          yield power_twoname % (s_name, s_attr)
          if attr == u'__init__':
              yield name_import % (s_name)
              yield power_onename % (s_name)
          yield name_import_rename % (d_name)
          yield from_import_rename % (s_name, s_attr, s_attr, s_attr, s_attr)
docs: u"""
      mapping1: A dict mapping py3k modules to all possible py2k replacements
      mapping2: A dict mapping py2k modules to the things they do
      This builds a HUGE pattern to match all ways that things can be imported