base = find_files(path=paths[0], substring=substring, check_ext=extensions[0], ignore_invisible=ignore_invisible, ignore_substring=ignore_substring)
rest = [find_files(path=paths[i], substring=substring, check_ext=extensions[i], ignore_invisible=ignore_invisible, ignore_substring=ignore_substring) for i in range(1,n)]
groups = {os.path.splitext(os.path.basename(f))[0].rstrip(rstrip):[f] for f in base}
for idx,r in enumerate(rest):
for f in r:
basename, ext = os.path.splitext(os.path.basename(f))
basename = basename.rstrip(rstrip)
try:
if extensions[idx+1] == "" or ext == extensions[idx+1]:
groups[basename].append(f)
except KeyError:
pass
if validity_check:
num = sorted([(len(v),k) for k,v in groups.items()])
for i in num[1:]:
if i[0] < num[0][0]:
print("Warning, key "%s" has less values than "key" %s." % (i[1], num[0][1]))
groups = {}
After Change
if validity_check:
lens = [len(groups[k]) for k in groups.keys()]
if len(set(lens)) > 1:
raise ValueError("Warning, some keys have more/less values than others. Set validity_check=False to ignore this warning.")
return groups