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 <karlp@tweak.au>
This commit is contained in:
@@ -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:
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
else:
|
||||
return None
|
||||
|
||||
return device
|
||||
|
||||
|
||||
Reference in New Issue
Block a user