Skip to content

Instantly share code, notes, and snippets.

@MosheBerman
Last active December 18, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MosheBerman/5766196 to your computer and use it in GitHub Desktop.
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?
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('.')
}
@nsabine
Copy link

nsabine commented Jun 12, 2013

Missing close paren on line 24

@nsabine
Copy link

nsabine commented Jun 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment