def repath(node, file, project_path):
matches = []
for root, dirnames, filenames in os.walk(project_path):
for x in filenames:
if x == file:
matches.append([root,os.path.join(root, x)])
elif x.split(".")[0] == file.split(".")[0]: #---> this second option is used when a file is useing ##### padding, we can match by name only
x_ext = x.split(".")[len(x.split("."))-1]
file_ext = file.split(".")[len(file.split("."))-1]
if x_ext == file_ext:
matches.append([root,os.path.join(root, x)])
if len(matches)>0:
return cmds.filePathEditor(node, repath=matches[0][0])
return None
评论列表
文章目录