Created
October 6, 2011 16:57
-
-
Save nickpascucci/1267938 to your computer and use it in GitHub Desktop.
Function to parse TODO comments from python source files.
This file contains 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
# TODO parser part 2 | |
def get_todos(files): | |
"""Create a list of TODO information based on the given files. | |
@param files: List of paths to Python source files. | |
@return: List of (person, date, file, line, text) tuples corresponding to | |
TODO comments in the given sources. | |
""" | |
comments = [] | |
for source_filename in files: | |
source_file = open(source_filename, "r") | |
line_number = 0 | |
for line in source_file: | |
line_number += 1 | |
line = line.strip() | |
if line.startswith("# TODO"): | |
elements = line.split(":") | |
todo_info = (elements[2], | |
elements[1], | |
source_filename, | |
str(line_number), | |
elements[3].strip()) | |
comments.append(todo_info) | |
return comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment