From fc844a797430c763b13d34bdf8796bd98cfb1b29 Mon Sep 17 00:00:00 2001 From: Suraj Deore Date: Tue, 1 Oct 2024 14:58:46 +0530 Subject: [PATCH] kind to schema --- lobster/tools/codebeamer/codebeamer.py | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lobster/tools/codebeamer/codebeamer.py b/lobster/tools/codebeamer/codebeamer.py index f9c7c012..fcdf8589 100755 --- a/lobster/tools/codebeamer/codebeamer.py +++ b/lobster/tools/codebeamer/codebeamer.py @@ -53,10 +53,10 @@ class References(Enum): REFS = "refs" - KIND = "kind" + SCHEMA = "schema" -SUPPORTED_REFERENCES = [References.REFS.value, References.KIND.value] +SUPPORTED_REFERENCES = [References.REFS.value, References.SCHEMA.value] def add_refs_refrences(req, flat_values_list): @@ -178,10 +178,10 @@ def to_lobster(cb_config, cb_item): assert isinstance(cb_config, dict) assert isinstance(cb_item, dict) and "id" in cb_item - SCHEMA_MAP = {'implementation', 'requirement', 'activity'} - SCHEMA = cb_config.get("kind", "requirement").lower() - if SCHEMA not in SCHEMA_MAP: - raise LOBSTER_Error(f"Unsupported SCHEMA '{SCHEMA}' provided in configuration.") + schema_map = {'implementation', 'requirement', 'activity'} + schema = cb_config.get("schema", "requirement").lower() + if schema not in schema_map: + raise LOBSTER_Error(f"Unsupported SCHEMA '{schema}' provided in configuration.") # This looks like it's business logic, maybe we should make this # configurable? @@ -209,7 +209,7 @@ def to_lobster(cb_config, cb_item): # Create common parameters for all kinds common_params = { 'tag': Tracing_Tag( - namespace="req" if SCHEMA == 'requirement' else "imp" if SCHEMA == 'implementation' else "act", + namespace="req" if schema == 'requirement' else "imp" if schema == 'implementation' else "act", tag=str(cb_item["id"]), version=cb_item["version"] ), @@ -224,7 +224,7 @@ def to_lobster(cb_config, cb_item): } # Construct the appropriate object based on 'kind' - if SCHEMA == 'requirement': + if schema == 'requirement': req = Requirement( **common_params, framework="codebeamer", @@ -233,7 +233,7 @@ def to_lobster(cb_config, cb_item): name= item_name ) - elif SCHEMA == 'implementation': + elif schema == 'implementation': req = Implementation( **common_params, language="python", @@ -304,10 +304,10 @@ def parse_cb_config(file_name): with open(file_name, "r", encoding='utf-8') as file: data = json.loads(file.read()) - SCHEMA = data.get("kind", "Requirement").lower() - SCHEMA_MAP = {'implementation', 'requirement', 'activity'} - if SCHEMA not in SCHEMA_MAP: - raise LOBSTER_Error(f"Unsupported SCHEMA '{SCHEMA}' provided in configuration.") + schema = data.get("schema", "Requirement").lower() + schema_map = {'implementation', 'requirement', 'activity'} + if schema not in schema_map: + raise LOBSTER_Error(f"Unsupported SCHEMA '{schema}' provided in configuration.") provided_config_keys = set(data.keys()) supported_references = set(SUPPORTED_REFERENCES) @@ -321,7 +321,7 @@ def parse_cb_config(file_name): for key, value in data.items(): json_config[key] = ensure_array_of_strings(value) - json_config["kind"] = SCHEMA + json_config["schema"] = schema return json_config @@ -373,7 +373,7 @@ def main(): mh = Message_Handler() cb_config = { - 'kind' : options.schema, + 'schema' : options.schema, "root" : options.cb_root, "base" : "%s/cb/api/v3" % options.cb_root, "user" : options.cb_user, @@ -386,7 +386,7 @@ def main(): if options.config: if os.path.isfile(options.config): cb_config["references"] = parse_cb_config(options.config) - cb_config["kind"] = cb_config["references"]['kind'] + cb_config["schema"] = cb_config["references"]['schema'] else: ap.error("cannot open config file '%s'" % options.config) @@ -455,16 +455,16 @@ def main(): except LOBSTER_Error: return 1 - kind_map = { + schema_map = { "requirement": Requirement, "implementation": Implementation, "activity": Activity } - kind_O = kind_map.get(cb_config["kind"].lower(), Requirement) + schema_obj = schema_map.get(cb_config["schema"].lower(), Requirement) output = sys.stdout if options.out is None else open(options.out, "w", encoding="UTF-8") with output as fd: - lobster_write(fd, kind_O, "lobster_codebeamer", items) + lobster_write(fd, schema_obj, "lobster_codebeamer", items) if options.out: print(f"Written {len(items)} requirements to {options.out}")