From 67a5b2af16236e7baa32de95e751bf7bed923715 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Wed, 17 Jan 2024 22:10:58 +0000 Subject: [PATCH] genlink: allow better usage as a tool calling sys.exit directly is so so ruuude. I'm not testing every path right now, but this is vastly better already. Signed-off-by: Karl Palsson --- scripts/genlink.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/genlink.py b/scripts/genlink.py index 18fd4de7..a7164cfc 100755 --- a/scripts/genlink.py +++ b/scripts/genlink.py @@ -24,7 +24,7 @@ import re import os -def get_device_data(data_file_path, device_id): +def get_device_data(data_file_path, device_id, exit_on_fail=True): device = { 'info': {}, 'defs': [], @@ -88,7 +88,10 @@ def get_device_data(data_file_path, device_id): # device was not found if len(device['family']) == 0: - sys.exit(1) + if exit_on_fail: + sys.exit(1) + else: + return None return device