Finds modules (recursively) in folder

    :param folder: root folder
    :param include_meta: whether include meta files like (__init__ or
        __version__)
    :return: list of modules
495536
def get_modules(folder, include_meta=False):
    
    files = [
        file
        for file in _get_modules(folder)
        if is_file(file)  # just files
    ]

    if not include_meta:
        files = [
            file
            for file in files
            if not Document(file).name.startswith("__")
        ]

    return files
1141100
public static ArrayList<File> getFilesAndDirectoriesInDirectoryTree(String path, String includeMask) {
		File file = new File(path);
		return getContentsInDirectoryTree(file, includeMask, true, true);
	}
1191989
def get_imported_module(self, context):
        
        if self.level == 0:
            return context.project.get_module(
                self.module_name, context.folder)
        else:
            return context.project.get_relative_module(
                self.module_name, context.folder, self.level)
856880
def getPathList(self, filesOrModules):
        
        pathList = []
        for fileOrMod in filesOrModules:
            if not os.path.exists(fileOrMod):
                # May be given module is not not a path,
                # then transform it to a path.
                try:
                    filepath = file_from_modpath(fileOrMod.split('.'))
                except (ImportError, SyntaxError):
                    # Could not load this module.
                    continue
                if not os.path.exists(filepath):
                    # Could not find this module in file system.
                    continue
                if os.path.basename(filepath) == "__init__.py":
                    filepath = os.path.dirname(filepath)
            else:
                filepath = fileOrMod
            pathList.append(filepath)
        return pathList
1059612
def find_plugins(self, path):
        
        ext = os.extsep+'py'
        files = []
        for (dirpath, dirnames, filenames) in os.walk(path):
            files.extend([os.path.join(dirpath, x) for x in filenames if x.endswith(ext)])
        plugins = []
        for f in files:
            try:
                mod = self.__import_file(f)
            except Exception:
                tb = traceback.format_exc()
                log.debug("Importing plugin from %s failed!\n%s" % (f, tb))
                continue
            # get all classes in the imported file
            members = inspect.getmembers(mod, lambda x: inspect.isclass(x))
            # only get classes which are defined, not imported, in mod
            classes = [m[1] for m in members if m[1].__module__ == mod.__name__]
            for c in classes:
                # if the class is derived from a supported type append it
                # we test if it is a subclass of a supported type but not a supported type itself
                # because that might be the abstract class
                if any(issubclass(c, supported) for supported in self.supportedTypes)\
                   and c not in self.supportedTypes:
                    plugins.append(c)
        return plugins
634577
def include_file(self, path, include_dirs = []):
        
        if self.include_includes:
            if self.debug: print("------------------                   Including a file: %s"%path)
            inc_dirs = include_dirs if include_dirs else self.include_dirs

            parser = LEMSFileParser(self, inc_dirs, self.include_includes)
            if os.access(path, os.F_OK):
                if not path in self.included_files:
                    parser.parse(open(path).read()) 
                    self.included_files.append(path)
                    return
                else:
                    if self.debug: print("Already included: %s"%path)
                    return
            else:
                for inc_dir in inc_dirs:
                    new_path = (inc_dir + '/' + path)
                    if os.access(new_path, os.F_OK):
                        if not new_path in self.included_files:
                            parser.parse(open(new_path).read())
                            self.included_files.append(new_path)
                            return
                        else:
                            if self.debug: print("Already included: %s"%path)
                            return
            msg = 'Unable to open ' + path
            if self.fail_on_missing_includes:
                raise Exception(msg)
            elif self.debug: 
                print(msg)
704197
def recursive_include(self, dir, pattern):
        
        full_pattern = os.path.join(dir, '**', pattern)
        found = [f for f in glob(full_pattern, recursive=True)
                 if not os.path.isdir(f)]
        self.extend(found)
        return bool(found)
563316
def get_plugin_modules(folders, package='plugins',
                       parentpackage='linkcheck.dummy'):
    """"""
    for folder in folders:
        for module in loader.get_folder_modules(folder, parentpackage):
            yield module
    for module in loader.get_package_modules(package):
        yield module
515166
def get_modules(path, prepend_module_root=True):
    
    module_root = os.path.split(path)[1]
    modules = list()
    for root, directories, filenames in os.walk(path):
        for filename in filenames:
            if _is_python_file(filename):
                directory = os.path.dirname(
                    os.path.realpath(
                        os.path.join(
                            root,
                            filename
                        )
                    )
                ).split(module_root)[-1].replace(
                    os.sep,  # e.g. '/'
                    '.'
                )
                directory = directory.replace('.', '', 1)

                module_name_parts = []
                if prepend_module_root:
                    module_name_parts.append(module_root)
                if directory:
                    module_name_parts.append(directory)

                if filename == '__init__.py':
                    path = root
                else:
                    module_name_parts.append(os.path.splitext(filename)[0])
                    path = os.path.join(root, filename)

                modules.append(('.'.join(module_name_parts), path))

    return modules
768534
def discover_plugins(dirs):
    
    # Scan all subdirectories recursively.
    for path in _iter_plugin_files(dirs):
        filename = op.basename(path)
        subdir = op.dirname(path)
        modname, ext = op.splitext(filename)
        file, path, descr = imp.find_module(modname, [subdir])
        if file:
            # Loading the module registers the plugin in
            # IPluginRegistry.
            try:
                mod = imp.load_module(modname, file, path, descr)  # noqa
            except Exception as e:  # pragma: no cover
                logger.exception(e)
            finally:
                file.close()
    return IPluginRegistry.plugins
1133187
def find_packages(path: str) -> List[str]:
    
    ret = []
    for root, _dir, files in os.walk(path):
        if '__init__.py' in files:
            ret.append(root.replace("/", "."))
    return sorted(ret)
197192
def main(directories):
    ''''''
    msg = 'Checking module "{}" from directory "{}" for coding errors.'
    api_checker = ApiChecker()
    resource_checker = ResourceChecker()
    errors = []
    modules = []
    for loader, mname, _ in pkgutil.walk_packages(directories):
        sys.path.append(os.path.abspath(loader.path))
        log.info(msg.format(mname, loader.path))
        modules.append(mname)
        import_module(mname)
    for api in Api:
        if api.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Api class: {}'.format(api.__name__))
        errors.extend(api_checker(api))
    for res in Resource:
        if res.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Resource class: {}'.format(res.__name__))
        errors.extend(resource_checker(res))
    else:
        log.info('All modules tested, no problem detected.')
    return errors
294740
def find_files(self):
        
        modules = self.evernode_app.get_modules()
        root_path = sys.path[0] if self.evernode_app.root_path is None \
            else self.evernode_app.root_path
        dirs = [dict(
            dir=os.path.join(root_path, 'resources', 'lang'), module="root")]
        for module_name in modules:
            modules_folder = 'modules{}%s'.format(os.sep)
            if module_name is not None:
                modules_folder = modules_folder % (module_name.strip(os.sep))
            else:
                continue
            path = os.path.join(
                root_path, modules_folder, 'resources', 'lang')
            if os.path.isdir(path):
                dirs.append(dict(dir=path, module=module_name))
        for dir in dirs:
            module_pack = {
                'name': dir['module'],
                'languages': [],
                'file_packs': []
            }
            for path, subdirs, files in os.walk(dir['dir']):
                for subdir in subdirs:
                    module_pack['languages'].append(subdir)
                for name in files:
                    module_pack['file_packs'].append(dict(
                        file=os.path.join(path, name),
                        name=name.rsplit('.', 1)[0].lower(),
                        language=path.split("lang%s" % (os.sep), 1)[1].strip()
                    ))
            self.module_packs.append(module_pack)
        for module_pack in self.module_packs:
            module_pack['file_packs'] = \
                list({v['file']: v for v in module_pack['file_packs']}
                     .values())
        if self.app.config['DEBUG']:
            print('--- Loaded Language Files ---')
            print("Loaded Dirs: " + str(dirs))
            print("Loaded Language Packs: " + str(self.module_packs))
441065
def read_dir(path, folder):
    
    full_path = os.path.join(path, folder)
    fnames = glob(f"{full_path}/*.*")
    directories = glob(f"{full_path}/*/")
    if any(fnames):
        return [os.path.relpath(f,path) for f in fnames]
    elif any(directories):
        raise FileNotFoundError("{} has subdirectories but contains no files. Is your directory structure is correct?".format(full_path))
    else:
        raise FileNotFoundError("{} folder doesn't exist or is empty".format(full_path))
118294
def get_modules(paths, toplevel=True):
    """"""
    modules = []
    for path in paths:
        path = os.path.abspath(path)
        if toplevel and path.endswith('.pyc'):
            sys.exit('.pyc files are not supported: {0}'.format(path))
        if os.path.isfile(path) and (path.endswith('.py') or toplevel):
            modules.append(path)
        elif os.path.isdir(path):
            subpaths = [
                os.path.join(path, filename)
                for filename in sorted(os.listdir(path))]
            modules.extend(get_modules(subpaths, toplevel=False))
        elif toplevel:
            sys.exit('Error: {0} could not be found.'.format(path))
    return modules
1371681
private List<File> locateModules() {
    File[] files = modRoot.listFiles();
    List<File> modFiles = new ArrayList<>();
    for (File file : files) {
      if (file.isDirectory()) {
        // Check to determine whether the directory is a valid module directory.
        boolean isValid = true;
        try {
          new ModuleIdentifier(file.getName());
        } catch (Exception e) {
          isValid = false;
        }

        // If the directory is a valid module name then check for a mod.json file.
        if (isValid) {
          File modJson = new File(file, MOD_JSON_FILE);
          if (modJson.exists()) {
            modFiles.add(file);
          }
        }
      }
    }
    return modFiles;
  }
793776
def get_includes(self, path):
        
        config = self.file_index.unfold_yaml(path)

        return self.get_includes_from_dict(config, extract=True)