in deepracer_systems_pkg/deepracer_systems_pkg/model_loader_module/model_loader_node.py [0:0]
def get_list_of_archives(self, search_path):
"""Helper function to get the list of files with the supported extensions
in the search path.
Args:
search_path (str): Path of the folder to search the files.
Returns:
list: List of file name which have the supported extensions.
"""
list_of_archives = list()
try:
for filename in os.listdir(search_path):
if not os.path.isfile(os.path.join(search_path, filename)):
continue
ext_list = list()
# Separate all archive extensions into a list.
name_no_ext = filename
while True:
components = os.path.splitext(name_no_ext)
name_no_ext = components[0]
ext = components[1]
if ext not in self.supported_exts:
break
ext_list.append(ext)
# Ignore files that we do not support.
if len(ext_list) == 0:
continue
list_of_archives.append(filename)
except Exception as ex:
self.get_logger().error(f"Failed to list {search_path}: {ex}")
return list_of_archives