Created
August 16, 2012 10:55
-
-
Save halit/3369259 to your computer and use it in GitHub Desktop.
My Recursive File Searcher in Python
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 dosyalama(yer, uzanti): | |
dosyalist = [] | |
for kok, altdizinler, dosyalar in os.walk(yer): | |
for dosya in dosyalar: | |
if dosya.endswith(uzanti): | |
dosyalist.append(os.path.join(kok,dosya)) | |
return dosyalist | |
def aramayap(yer, kelime, uzanti): | |
yer = str(yer) | |
kelime = str(kelime) | |
uzanti = str(uzanti) | |
dosyalar = dosyalama(yer, uzanti) | |
for dosya in dosyalar: | |
satirlar = open(dosya) | |
for satir in satirlar: | |
if satir.find(kelime) > 0: | |
if self.bulunan.count(dosya) == 0: | |
self.bulunan.append(dosya) | |
return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment