minor logic optimisation

This commit is contained in:
mightbesimon 2023-06-25 04:47:20 +12:00
parent f13654e6d8
commit cc5fe74d6b

View file

@ -32,10 +32,10 @@ def get_image_paths(dir_path, image_extensions=image_extensions, subdirs=False,
else: else:
gen = scandir(str(dir_path)) gen = scandir(str(dir_path))
for x in list(gen): for x in gen:
if any([x.name.lower().endswith(ext) for ext in image_extensions]): if any(x.name.lower().endswith(ext) for ext in image_extensions): # listcomp is not needed, any() can handle gencomp
result.append( x.path if not return_Path_class else Path(x.path) ) result.append( Path(x) if return_Path_class else x.path ) # avoid unnecessary negative condition
return sorted(result) return result # scandir should already be sorted
def get_image_unique_filestem_paths(dir_path, verbose_print_func=None): def get_image_unique_filestem_paths(dir_path, verbose_print_func=None):
result = get_image_paths(dir_path) result = get_image_paths(dir_path)