docs: def extend_path(pth, name):
    '''
    Better implementation of #pkgutil.extend_path()  which adds support for
    zipped Python eggs. The original #pkgutil.extend_path() gets mocked by this
    function inside the #localimport context.
    '''
  
    def zip_isfile(z, name):
      name.rstrip('/')
      return name in z.namelist()
  
    pname = os.path.join(*name.split('.'))
    zname = '/'.join(name.split('.'))
    init_py = '__init__' + os.extsep + 'py'
    init_pyc = '__init__' + os.extsep + 'pyc'
    init_pyo = '__init__' + os.extsep + 'pyo'
  
    mod_path = list(pth)
    for path in sys.path:
      if zipfile.is_zipfile(path):
        try:
          egg = zipfile.ZipFile(path, 'r')
          addpath = (
            zip_isfile(egg, zname + '/__init__.py') or
            zip_isfile(egg, zname + '/__init__.pyc') or
            zip_isfile(egg, zname + '/__init__.pyo'))
          fpath = os.path.join(path, path, zname)
          if addpath and fpath not in mod_path:
            mod_path.append(fpath)
        except (zipfile.BadZipfile, zipfile.LargeZipFile):
          pass  # xxx: Show a warning at least?
      else:
        path = os.path.join(path, pname)
        if os.path.isdir(path) and path not in mod_path:
          addpath = (
            os.path.isfile(os.path.join(path, init_py)) or
            os.path.isfile(os.path.join(path, init_pyc)) or
            os.path.isfile(os.path.join(path, init_pyo)))
          if addpath and path not in mod_path:
            mod_path.append(path)
  
    return [os.path.normpath(x) for x in mod_path]