def METHOD_NAME(modules):
  """Look at __file__ of each module, and classify them as Python or C."""
  for module, full_path in modules:
    #print 'OLD', module, full_path
    num_parts = module.count('.') + 1
    i = len(full_path)
    # Do it once more in this case
    if full_path.endswith('/__init__.pyc') or \
       full_path.endswith('__init__.py'):
      i = full_path.rfind('/', 0, i)
    for _ in xrange(num_parts):
      i = full_path.rfind('/', 0, i)
    #print i, full_path[i+1:]
    rel_path = full_path[i + 1:]
    # Depending on whether it's cached, the __file__ attribute on the module
    # ends with '.py' or '.pyc'.
    if full_path.endswith('.py'):
      yield PY_MODULE, full_path, rel_path
    elif full_path.endswith('.pyc'):
      yield PY_MODULE, full_path[:-1], rel_path[:-1]
    else:
      # .so file
      yield C_MODULE, module, full_path