[sdk/kde-builder] /: _read_branch_groups()
Andrew Shark <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit bacd986421aebd6ec190c7c4f1cfde1a25853ed9 by Andrew Shark.
Committed on 18/08/2026 at 23:34.
Pushed by ashark into branch 'master'.
_read_branch_groups()
M +10 -13 kde_builder/metadata/metadata.py
M +0 -2 kde_builder/module/branch_group_resolver.py
R +0 -0 tests/fixtures/repo-metadata/branch-groups.yaml [from: tests/fixtures/repo-metadata/kde-dependencies/branch-groups.yaml - 100% similarity]
https://invent.kde.org/sdk/kde-builder/-/commit/bacd986421aebd6ec190c7c4f1cfde1a25853ed9
diff --git a/kde_builder/metadata/metadata.py b/kde_builder/metadata/metadata.py
index fc2ae732..a68eb2f5 100644
--- a/kde_builder/metadata/metadata.py
+++ b/kde_builder/metadata/metadata.py
@@ -21,7 +21,7 @@ class Metadata:
self.path_to_metadata = path_to_metadata
self.ignored_projects = self._ignored_modules()
- self.branch_groups = self._logical_module_groups()
+ self.branch_groups = self._read_branch_groups()
def _ignored_modules(self) -> list[str]:
"""
@@ -56,26 +56,23 @@ class Metadata:
fh.close()
return ignore_modules
- def _logical_module_groups(self) -> dict:
+ def _read_branch_groups(self) -> dict:
"""
Return a dict of the branch-groups.yaml file.
The metadata should already be downloaded.
"""
- path = self.path_to_metadata + "/kde-dependencies/branch-groups.yaml"
+ path = self.path_to_metadata + "/branch-groups.yaml"
if Debug().is_testing():
- path = KB_REPO_DIR + "/tests/fixtures/repo-metadata/kde-dependencies/branch-groups.yaml"
+ path = KB_REPO_DIR + "/tests/fixtures/repo-metadata/branch-groups.yaml"
try:
- fh = open(path, "r")
- except IOError:
- raise ProgramError("Unable to read branch-groups.yaml")
+ with open(path, "r") as file:
+ yaml_dict = yaml.safe_load(file)
+ except FileNotFoundError:
+ raise KBRuntimeError("Unable to read branch-groups.yaml")
+ except yaml.YAMLError:
+ raise KBRuntimeError(f"Unable to load branch-groups.yaml")
- try:
- yaml_str = fh.read() # slurps the whole file
- yaml_dict = yaml.safe_load(yaml_str)
- fh.close()
- except Exception as e:
- raise KBRuntimeError(f"Unable to load branch-groups from {path}! :(\n\t{e}")
return yaml_dict
diff --git a/kde_builder/module/branch_group_resolver.py b/kde_builder/module/branch_group_resolver.py
index 5b957c8d..b6cc1873 100644
--- a/kde_builder/module/branch_group_resolver.py
+++ b/kde_builder/module/branch_group_resolver.py
@@ -9,8 +9,6 @@ from __future__ import annotations
class ModuleBranchGroupResolver:
"""
Provides an object that can be used to look up the appropriate git branch to use for a given KDE project and given desired branch group.
-
- Uses supplied YAML data (from repo-metadata's /kde-dependencies directory).
"""
def __init__(self, yaml_data: dict):
diff --git a/tests/fixtures/repo-metadata/kde-dependencies/branch-groups.yaml b/tests/fixtures/repo-metadata/branch-groups.yaml
similarity index 100%
rename from tests/fixtures/repo-metadata/kde-dependencies/branch-groups.yaml
rename to tests/fixtures/repo-metadata/branch-groups.yaml