(self)
Fill the cache of potential modules and packages for this directory.
Fill the cache of potential modules and packages for this directory.
Fill the cache of potential modules and packages for this directory .
def _fill_cache(self):
        """Fill the cache of potential modules and packages for this directory."""
        path = self.path
        try:
            contents = _os.listdir(path or _os.getcwd())
        except (FileNotFoundError, PermissionError, NotADirectoryError):
            # Directory has either been removed, turned into a file, or made
            # unreadable.
            contents = []
        # We store two cached versions, to handle runtime changes of the
        # PYTHONCASEOK environment variable.
        if not sys.platform.startswith('win'):
            self._path_cache = set(contents)
        else:
            # Windows users can import modules with case-insensitive file
            # suffixes (for legacy reasons). Make the suffix lowercase here
            # so it's done once instead of for every import. This is safe as
            # the specified suffixes to check against are always specified in a
            # case-sensitive manner.
            lower_suffix_contents = set()
            for item in contents:
                name, dot, suffix = item.partition('.')
                if dot:
                    new_name = '{}.{}'.format(name, suffix.lower())
                else:
                    new_name = name
                lower_suffix_contents.add(new_name)
            self._path_cache = lower_suffix_contents
        if sys.platform.startswith(_CASE_INSENSITIVE_PLATFORMS):
            self._relaxed_path_cache = {fn.lower() for fn in contents}
def _fill_cache ( self ) : path = self . path try : contents = _os . listdir ( path or _os . getcwd ( ) ) except ( FileNotFoundError , PermissionError , NotADirectoryError ) : # Directory has either been removed, turned into a file, or made # unreadable. contents = [ ] # We store two cached versions, to handle runtime changes of the # PYTHONCASEOK environment variable. if not sys . platform . startswith ( 'win' ) : self . _path_cache = set ( contents ) else : # Windows users can import modules with case-insensitive file # suffixes (for legacy reasons). Make the suffix lowercase here # so it's done once instead of for every import. This is safe as # the specified suffixes to check against are always specified in a # case-sensitive manner. lower_suffix_contents = set ( ) for item in contents : name , dot , suffix = item . partition ( '.' ) if dot : new_name = '{}.{}' . format ( name , suffix . lower ( ) ) else : new_name = name lower_suffix_contents . add ( new_name ) self . _path_cache = lower_suffix_contents if sys . platform . startswith ( _CASE_INSENSITIVE_PLATFORMS ) : self . _relaxed_path_cache = { fn . lower ( ) for fn in contents }