Created
June 10, 2019 06:50
-
-
Save p208p2002/08d66fe4d9009db0db26ac83c1074e7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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