[elbe-devel] [PATCH 1/2] Assert that the buildtype in XML is valid

dion at linutronix.de dion at linutronix.de
Thu Jun 27 17:58:21 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/xmldefaults.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/elbepack/xmldefaults.py b/elbepack/xmldefaults.py
index 9793d2f3..1979b67d 100644
--- a/elbepack/xmldefaults.py
+++ b/elbepack/xmldefaults.py
@@ -200,14 +200,9 @@ class ElbeDefaults(object):
 
     def __init__(self, build_type):
 
-        if build_type not in defaults:
-            print("Please specify a valid buildtype.")
-            print("Valid buildtypes:")
-            print(defaults.keys())
-            print("Please specify a valid buildtype.")
-            print("Valid buildtypes:")
-            print(list(defaults.keys()))
-            sys.exit(20)
+        assert build_type in defaults, ("Invalid buildtype %s\n"
+                                        "Valid buildtypes are:\n  - %s" %
+                                        (build_type, "\n  - ".join(defaults.keys())))
 
         self.defaults = defaults[build_type]
         self.defaults["nicmac"] = get_random_mac()
-- 
2.11.0




More information about the elbe-devel mailing list