Last active
December 18, 2015 10:09
-
-
Save MosheBerman/5766196 to your computer and use it in GitHub Desktop.
There's a syntax error on line 30, but I have no clue what the error is. Help?
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
import os | |
import keyword | |
import sys | |
class Toodles: | |
def walkAndList(directory): | |
for dirname, dirnames, filenames in os.walk(directory): | |
# print path to all filenames. | |
for filename in filenames: | |
workingFilename = os.path.join(dirname, filename) | |
if(isSourceFile(filename)): | |
listOccurrencesOfToDoInFile(filename) | |
# Advanced usage: | |
# editing the 'dirnames' list will stop os.walk() from recursing into there. | |
if '.git' in dirnames: | |
# don't go into any .git directories. | |
dirnames.remove('.git') | |
for dirs in dirnames: | |
self.walkAndList(os.path.join(dirname, dirs) | |
# Find occurences of "todo" and "fixme" in a file | |
# If we find such an occurence, print the filename, | |
# the line number, and the line itself. | |
def listOccurrencesOfToDoInFile(aFileName): | |
input = open(aFileName) | |
currentLine = 1 | |
for (line in input): | |
line = line.lower() | |
currentLine = currentLine + 1 | |
needle = "todo" | |
if (needle in line): | |
sys.stdout.write(aFileName + " (" + str(currentLine) + ")" + line) | |
#Todo: add a comment | |
def isSourceFile(self, name): | |
fileName, fileExtension = os.path.splitext(name) | |
if (".m" in fileExtension or ".c" in fileExtension or ".h" in fileExtension): | |
return True | |
return False | |
if ( __name__ == "__main__") { | |
a = Toodles() | |
a.walkAndList('.') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Missing close paren on line 24