diff --git a/osbuild/meta.py b/osbuild/meta.py index 25495b15..3b4a7616 100644 --- a/osbuild/meta.py +++ b/osbuild/meta.py @@ -7,8 +7,8 @@ this context). Additionally, it provides classes and functions to do schema validation of OSBuild manifests and stage options. A central `Index` class can be used to obtain stage and schema -information. For the former a `StageInfo` class is returned via -`Index.get_stage_info`, which contains meta-information about +information. For the former a `ModuleInfo` class is returned via +`Index.get_module_info`, which contains meta-information about the individual stages. Schemata, obtained via `Index.get_schema` is represented via a `Schema` class that can in turn be used to validate the individual components. @@ -260,11 +260,11 @@ class Schema: return self.check().valid -class StageInfo: +class ModuleInfo: """Meta information about a stage Represents the information about a osbuild pipeline - stage or assembler (here also considered to be a stage). + modules, like a stage or an assembler. Contains the short description (`desc`), a longer description (`info`) and the JSON schema of valid options (`opts`). The `validate` method will check a the options @@ -311,7 +311,7 @@ class StageInfo: return schema @classmethod - def load(cls, root, klass, name) -> Optional["StageInfo"]: + def load(cls, root, klass, name) -> Optional["ModuleInfo"]: names = ['STAGE_INFO', 'STAGE_DESC', 'STAGE_OPTS'] def value(a): @@ -359,18 +359,18 @@ class Index: def __init__(self, path: str): self.path = path - self._stage_info = {} + self._module_info = {} self._schemata = {} - def get_stage_info(self, klass, name) -> Optional[StageInfo]: - """Obtain `StageInfo` for a given stage or assembler""" + def get_module_info(self, klass, name) -> Optional[ModuleInfo]: + """Obtain `ModuleInfo` for a given stage or assembler""" - if (klass, name) not in self._stage_info: + if (klass, name) not in self._module_info: - info = StageInfo.load(self.path, klass, name) - self._stage_info[(klass, name)] = info + info = ModuleInfo.load(self.path, klass, name) + self._module_info[(klass, name)] = info - return self._stage_info[(klass, name)] + return self._module_info[(klass, name)] def get_schema(self, klass, name=None) -> Schema: """Obtain a `Schema` for `klass` and `name` (optional) @@ -391,7 +391,7 @@ class Index: with open(path, "r") as f: schema = json.load(f) elif klass in ["Stage", "Assembler"]: - info = self.get_stage_info(klass, name) + info = self.get_module_info(klass, name) if info: schema = info.schema else: diff --git a/test/test_osbuild.py b/test/test_osbuild.py index f811826e..56132f49 100644 --- a/test/test_osbuild.py +++ b/test/test_osbuild.py @@ -77,17 +77,17 @@ class TestDescriptions(unittest.TestCase): } }) - def test_stageinfo(self): - def list_stages(base, klass): + def test_moduleinfo(self): + def list_modules(base, klass): return [(klass, f) for f in os.listdir(base) if f.startswith("org.osbuild")] - stages = list_stages("stages", "Stage") - stages += list_stages("assemblers", "Assembler") + modules = list_modules("stages", "Stage") + modules += list_modules("assemblers", "Assembler") - for stage in stages: - klass, name = stage + for module in modules: + klass, name = module try: - info = osbuild.meta.StageInfo.load(os.curdir, klass, name) + info = osbuild.meta.ModuleInfo.load(os.curdir, klass, name) schema = osbuild.meta.Schema(info.schema, name) res = schema.check() if not res: diff --git a/test/test_stageinfo.py b/test/test_stageinfo.py index 8a9321ab..0a8fda85 100644 --- a/test/test_stageinfo.py +++ b/test/test_stageinfo.py @@ -3,7 +3,7 @@ import json import unittest from pathlib import Path -class TestStageInfo(unittest.TestCase): +class TestModuleInfo(unittest.TestCase): @staticmethod def iter_stages(stagedir): '''Yield executable files in `stagedir`''' @@ -12,7 +12,7 @@ class TestStageInfo(unittest.TestCase): yield p @staticmethod - def get_stage_info(stage: Path) -> dict: + def get_module_info(stage: Path) -> dict: '''Return the STAGE_* variables from the given stage.''' # NOTE: This works for now, but stages should probably have some # standard way of dumping this info so we (and other higher-level @@ -44,9 +44,9 @@ class TestStageInfo(unittest.TestCase): self.stages = list(self.iter_stages(self.stages_dir)) self.assemblers = list(self.iter_stages(self.assemblers_dir)) - def check_stage_info(self, stage): + def check_module_info(self, module): with self.subTest(check="STAGE_{INFO,DESC,OPTS} vars present"): - stage_info = self.get_stage_info(stage) + stage_info = self.get_module_info(module) self.assertIn("STAGE_DESC", stage_info) self.assertIn("STAGE_INFO", stage_info) self.assertIn("STAGE_OPTS", stage_info) @@ -66,10 +66,10 @@ class TestStageInfo(unittest.TestCase): for prop in stage_opts.get("required", []): self.assertIn(prop, stage_opts["properties"]) - def test_stage_info(self): + def test_module_info(self): for stage in self.stages: with self.subTest(stage=stage.name): - self.check_stage_info(stage) + self.check_module_info(stage) for assembler in self.assemblers: with self.subTest(assembler=assembler.name): - self.check_stage_info(assembler) + self.check_module_info(assembler)