config: Public interface amendments

Add a repo_paths argument to find_missing_repos, with the default value
unchanged.

Factor out the contents of the loop in _get_repo_dict in config.py to
get_repo so that Repo instances can be created one at a time. The
behavior of _get_repo_dict is unchanged.

Add get_repos_config so it is possible to check whether a repo name
exists just in the config, as opposed to whether a Repo instance has
been created.

Add get_config to allow the config dict to be read in its entirety for
debugging purposes.

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
[Jan: fix minor style issue]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Peter Hoyes 2022-07-08 16:45:08 +02:00 committed by Jan Kiszka
parent 71cf5dc17b
commit 958b0ab2f8

View File

@ -68,16 +68,27 @@ class Config:
"""
return self._config.get('build_system', '')
def find_missing_repos(self):
def find_missing_repos(self, repo_paths={}):
"""
Returns repos that are in config but not on disk
"""
repo_paths = {}
(self._config, missing_repo_names) = \
self.handler.get_config(repos=repo_paths)
return missing_repo_names
def get_config(self):
"""
Returns the config dict.
"""
return self._config
def get_repos_config(self):
"""
Returns the repository configuration
"""
return self._config.get('repos', {})
def get_repos(self):
"""
Returns the list of repos.
@ -88,23 +99,25 @@ class Config:
self.repo_dict = self._get_repo_dict()
return list(self.repo_dict.values())
def get_repo(self, name):
"""
Returns a `Repo` instance for the configuration with the key
`name`.
"""
repo_defaults = self._config.get('defaults', {}).get('repos', {})
config = self.get_repos_config()[name] or {}
return Repo.factory(name,
config,
repo_defaults,
self.top_repo_path)
def _get_repo_dict(self):
"""
Returns a dictionary containing the repositories with
their names (as it is defined in the config file) as keys
and the `Repo` instances as values.
"""
repo_config_dict = self._config.get('repos', {})
repo_defaults = self._config.get('defaults', {}).get('repos', {})
repo_dict = {}
for repo in repo_config_dict:
repo_config_dict[repo] = repo_config_dict[repo] or {}
repo_dict[repo] = Repo.factory(repo,
repo_config_dict[repo],
repo_defaults,
self.top_repo_path)
return repo_dict
return {name: self.get_repo(name) for name in self.get_repos_config()}
def get_bitbake_targets(self):
"""