def _load_repo(self, repo_path): repo_layout, layout_config_path = repolayoututil.get_repo_layout( repo_path) if layout_config_path: logutil.start_msg('Using layout configuration from') logutil.end_msg(layout_config_path) for gd in repo_layout.group_dirs: gd_path = os.path.join(repo_path, gd) if os.path.isdir(gd_path): self._load_repo_package_groups(gd_path) for sad in repo_layout.stand_alone_package_dirs: sad_path = os.path.join(repo_path, sad) if os.path.isdir(sad_path): self._load_repo_stdalone_packages( sad_path, repounits.PackageType.PACKAGE_STAND_ALONE) for sad in repo_layout.app_package_dirs: sad_path = os.path.join(repo_path, sad) if os.path.isdir(sad_path): self._load_repo_stdalone_packages( sad_path, repounits.PackageType.PACKAGE_APPLICATION) for sad in repo_layout.third_party_package_dirs: sad_path = os.path.join(repo_path, sad) if os.path.isdir(sad_path): self._load_repo_thirdparty_dirs(sad_path) for pg in repo_layout.group_abs_dirs: if pg == '.': pg_path = repo_path else: pg_path = os.path.join(repo_path, pg) if repoloadutil.is_package_group_path(pg_path): self._load_repo_one_package_group(pg_path)
def _load_repo_package_groups(self, path): dirs = next(os.walk(path))[1] package_group_paths = [] for d in dirs: dir_path = os.path.join(path, d) if repoloadutil.is_package_group_path(dir_path): package_group_paths.append(dir_path) for path in package_group_paths: self._load_repo_one_package_group(path)
def get_repo_layout(repo_root_path): """Get the directory layout of a repository. Args: repo_root_path (str): Path to the root of the repository. Returns: repo_layout (RepoLayout), config_file (str) config_file is the the path to the configuration file from which the configuration is derived. The value is 'None' if the default configuration is used. Raises: IOError: An error occured while accessing the configuration file. InvalidConfigFileError: Invalid configuration file. """ layout_config_path = os.path.join(repo_root_path, '.bdelayoutconfig') if not os.path.isfile(layout_config_path): repo_layout = repolayout.RepoLayout() if repoloadutil.is_package_group_path(repo_root_path): # API has repositories where the root of the repo contains just one # package group. We want to support this instrisically. repo_layout.group_dirs = [] repo_layout.app_package_dirs = [] repo_layout.stand_alone_package_dirs = [] repo_layout.third_party_package_dirs = [] repo_layout.group_abs_dirs = ['.'] elif os.path.isdir(os.path.join(repo_root_path, 'src')): # Attempt to automatically support repos using the "src" directory # instead of the repo root to store typical directories such as # "groups" and "adapters". If this simple heuristic fails for a # repo, use ".bdelayoutconfig" to customize its layout manually. repo_layout.group_dirs = ['src/groups', 'src/enterprise', 'src/wrappers'] repo_layout.app_package_dirs = ['src/applications'] repo_layout.stand_alone_package_dirs = ['src/adapters', 'src/standalones'] repo_layout.third_party_package_dirs = ['src/third-party'] repo_layout.group_abs_dirs = [] else: repo_layout.group_dirs = ['groups', 'enterprise', 'wrappers'] repo_layout.app_package_dirs = ['applications'] repo_layout.stand_alone_package_dirs = ['adapters', 'standalones'] repo_layout.third_party_package_dirs = ['thirdparty', 'third-party'] repo_layout.group_abs_dirs = [] return repo_layout, None with open(layout_config_path) as f: repo_layout = parse_repo_layout_from_json(f) return repo_layout, layout_config_path
def get_repo_layout(repo_root_path): """Get the directory layout of a repository. Args: repo_root_path (str): Path to the root of the repository. Returns: repo_layout (RepoLayout), config_file (str) config_file is the the path to the configuration file from which the configuration is derived. The value is 'None' if the default configuration is used. Raises: IOError: An error occured while accessing the configuration file. InvalidConfigFileError: Invalid configuration file. """ layout_config_path = os.path.join(repo_root_path, '.bdelayoutconfig') if not os.path.isfile(layout_config_path): repo_layout = repolayout.RepoLayout() if repoloadutil.is_package_group_path(repo_root_path): # API has repositories where the root of the repo contains just one # package group. We want to support this instrisically. repo_layout.group_dirs = [] repo_layout.app_package_dirs = [] repo_layout.stand_alone_package_dirs = [] repo_layout.third_party_package_dirs = [] repo_layout.group_abs_dirs = ['.'] elif os.path.isdir(os.path.join(repo_root_path, 'src')): # Attempt to automatically support repos using the "src" directory # instead of the repo root to store typical directories such as # "groups" and "adapters". If this simple heuristic fails for a # repo, use ".bdelayoutconfig" to customize its layout manually. repo_layout.group_dirs = ['src/groups', 'src/enterprise', 'src/wrappers'] repo_layout.app_package_dirs = ['src/applications'] repo_layout.stand_alone_package_dirs = ['src/adapters', 'src/standalones'] repo_layout.third_party_package_dirs = ['src/third-party'] repo_layout.group_abs_dirs = [] else: repo_layout.group_dirs = ['groups', 'enterprise', 'wrappers'] repo_layout.app_package_dirs = ['applications'] repo_layout.stand_alone_package_dirs = ['adapters', 'standalones'] repo_layout.third_party_package_dirs = ['third-party'] repo_layout.group_abs_dirs = [] return repo_layout, None with open(layout_config_path) as f: repo_layout = parse_repo_layout_from_json(f) return repo_layout, layout_config_path
def get_repo_layout(repo_root_path): """Get the directory layout of a repository. Args: repo_root_path (str): Path to the root of the repository. Returns: repo_layout (RepoLayout), config_file (str) config_file is the the path to the configuration file from which the configuration is derived. The value is 'None' if the default configuration is used. Raises: IOError: An error occured while accessing the configuration file. InvalidConfigFileError: Invalid configuration file. """ layout_config_path = os.path.join(repo_root_path, '.bdelayoutconfig') if not os.path.isfile(layout_config_path): repo_layout = repolayout.RepoLayout() if repoloadutil.is_package_group_path(repo_root_path): # API has repositories where the root of the repo contains just one # package group. We want to support this instrisically. repo_layout.group_dirs = [] repo_layout.app_package_dirs = [] repo_layout.stand_alone_package_dirs = [] repo_layout.third_party_package_dirs = [] repo_layout.group_abs_dirs = ['.'] else: repo_layout.group_dirs = ['groups', 'enterprise', 'wrappers'] repo_layout.app_package_dirs = ['applications'] repo_layout.stand_alone_package_dirs = ['adapters'] repo_layout.third_party_package_dirs = ['third-party'] repo_layout.group_abs_dirs = [] return repo_layout, None with open(layout_config_path) as f: repo_layout = parse_repo_layout_from_json(f) return repo_layout, layout_config_path