def isModule(self, dotted_name, extrapath=None):
        """Is ``dotted_name`` the name of a module?"""
        try:
            return self._module_cache[(dotted_name, extrapath)]
        except KeyError:
            pass
        if dotted_name in sys.modules or dotted_name in self.builtin_modules:
            return dotted_name
        filename = dotted_name.replace('.', os.path.sep)
        if extrapath:
            for ext in self._exts:
                candidate = os.path.join(extrapath, filename) + ext
                if os.path.exists(candidate):
                    modname = self.filenameToModname(candidate)
                    self._module_cache[(dotted_name, extrapath)] = modname
                    return modname
        try:
            return self._module_cache[(dotted_name, None)]
        except KeyError:
            pass
        for dir in self.path:
            if os.path.isfile(dir):
                if dir.endswith('.egg-info'):
                    # distribute creates a setuptools-blah-blah.egg-info
                    # that ends up in sys.path
                    continue
                try:
                    zf = zipfile.ZipFile(dir)
                except zipfile.BadZipfile:
                    self.warn(dir, "%s: not a directory or zip file", dir)
                    continue
                names = zf.namelist()
                for ext in self._exts:
                    candidate = filename + ext
                    if candidate in names:
                        modname = filename.replace(os.path.sep, '.')
                        self._module_cache[(dotted_name, extrapath)] = modname
                        self._module_cache[(dotted_name, None)] = modname
                        return modname
            else:
                for ext in self._exts:
                    candidate = os.path.join(dir, filename) + ext
                    if os.path.exists(candidate):
                        modname = self.filenameToModname(candidate)
                        self._module_cache[(dotted_name, extrapath)] = modname
                        self._module_cache[(dotted_name, None)] = modname
                        return modname
        return None
def isModule ( self , dotted_name , extrapath = None ) : try : return self . _module_cache [ ( dotted_name , extrapath ) ] except KeyError : pass if dotted_name in sys . modules or dotted_name in self . builtin_modules : return dotted_name filename = dotted_name . replace ( '.' , os . path . sep ) if extrapath : for ext in self . _exts : candidate = os . path . join ( extrapath , filename ) + ext if os . path . exists ( candidate ) : modname = self . filenameToModname ( candidate ) self . _module_cache [ ( dotted_name , extrapath ) ] = modname return modname try : return self . _module_cache [ ( dotted_name , None ) ] except KeyError : pass for dir in self . path : if os . path . isfile ( dir ) : if dir . endswith ( '.egg-info' ) : continue try : zf = zipfile . ZipFile ( dir ) except zipfile . BadZipfile : self . warn ( dir , "%s: not a directory or zip file" , dir ) continue names = zf . namelist ( ) for ext in self . _exts : candidate = filename + ext if candidate in names : modname = filename . replace ( os . path . sep , '.' ) self . _module_cache [ ( dotted_name , extrapath ) ] = modname self . _module_cache [ ( dotted_name , None ) ] = modname return modname else : for ext in self . _exts : candidate = os . path . join ( dir , filename ) + ext if os . path . exists ( candidate ) : modname = self . filenameToModname ( candidate ) self . _module_cache [ ( dotted_name , extrapath ) ] = modname self . _module_cache [ ( dotted_name , None ) ] = modname return modname return None
Is ``dotted_name`` the name of a module?