Skip to content

Instantly share code, notes, and snippets.

@p208p2002
Created June 10, 2019 06:50
Show Gist options
  • Select an option

  • Save p208p2002/08d66fe4d9009db0db26ac83c1074e7e to your computer and use it in GitHub Desktop.

Select an option

Save p208p2002/08d66fe4d9009db0db26ac83c1074e7e to your computer and use it in GitHub Desktop.
def __searchTarget(self):
path = self.searchPath
files = []
searchType = self.searchType
searchStr = self.patternKey
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
searchTarget = 0
if(searchType == 1):
searchTarget = f
elif(searchType == 2):
searchTarget = d
for target in searchTarget:
patternStr = re.compile(searchStr)
results = patternStr.findall(target)
if(len(results)>0):
files.append(os.path.join(r, target))
counter = 0
if(len(files)==0):
print("no match result")
return ''
msg = ''
for f in files:
print(counter,f)
msg=msg+'['+str(counter)+'] '+str(f)+'\n'
counter += 1
self.files = files
return msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment