From 0a6edbd046503b11c498ded330128822dfc21ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Wed, 27 Nov 2024 09:52:13 +0100 Subject: [PATCH 1/2] Improve error message This makes the error more clear in situations that the missing attribute name is ambiguous. For example, if the attribute name is `check`, the message was `check is required` which some people understood as the whole OVAL file wasn't there. --- ssg/oval_object_model/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssg/oval_object_model/general.py b/ssg/oval_object_model/general.py index 52198879305..976ea8a0240 100644 --- a/ssg/oval_object_model/general.py +++ b/ssg/oval_object_model/general.py @@ -11,7 +11,7 @@ def required_attribute(_xml_el, _key): if _key in _xml_el.attrib: return _xml_el.get(_key) raise ValueError( - "%s is required but was not found in:\n%s" % (_key, repr(_xml_el.attrib)) + "%s attribute is required but was not found in %s element:\n%s" % (_key, _xml_el.tag, repr(_xml_el.attrib)) ) From 445a855bdb784001473738428b539669e81562bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Wed, 27 Nov 2024 15:49:33 +0100 Subject: [PATCH 2/2] Fix Code Climate problem --- ssg/oval_object_model/general.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ssg/oval_object_model/general.py b/ssg/oval_object_model/general.py index 976ea8a0240..556062f138f 100644 --- a/ssg/oval_object_model/general.py +++ b/ssg/oval_object_model/general.py @@ -11,7 +11,8 @@ def required_attribute(_xml_el, _key): if _key in _xml_el.attrib: return _xml_el.get(_key) raise ValueError( - "%s attribute is required but was not found in %s element:\n%s" % (_key, _xml_el.tag, repr(_xml_el.attrib)) + "%s attribute is required but was not found in %s element:\n%s" % ( + _key, _xml_el.tag, repr(_xml_el.attrib)) )