in src/local_gpu_verifier/src/verifier/rim/__init__.py [0:0]
def read(base_RIM_path = None, content = None):
""" Static method that reads the signed base RIM from the disk.
Argument:
base_RIM_path (str) : the path to the signed base RIM.
content (str) : the content of the RIM file as a string.
Returns:
root (lxml.etree._Element) : the root element of the base RIM.
"""
if base_RIM_path is not None and content is None:
try:
assert type(base_RIM_path) is str
with open(base_RIM_path, 'rb') as f:
read_data = f.read()
except OSError:
event_log.error(f'Unable to read {base_RIM_path} \nPlease provide a valid RIM file.')
raise RIMFetchError(f'Unable to read {base_RIM_path} \nPlease provide a valid RIM file.')
file_stream = io.BytesIO(read_data)
elif base_RIM_path is None and content is not None:
file_stream = io.StringIO(content)
else:
raise RIMFetchError("Invalid parameters!!")
parser = etree.XMLParser(resolve_entities=False)
new_swidtag_tree = etree.parse(file_stream, parser)
new_root = new_swidtag_tree.getroot()
return new_root