Autogenerating todos
authorepage <eopage@byu.net>
Fri, 27 Mar 2009 00:33:07 +0000 (00:33 +0000)
committerepage <eopage@byu.net>
Fri, 27 Mar 2009 00:33:07 +0000 (00:33 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@254 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

Makefile
TODO [deleted file]
src/evo_backend.py
support/todo.py [new file with mode: 0755]

index a79ef30..88e8bf8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ DATA=$(foreach type, $(DATA_TYPES), $(shell find $(SOURCE_PATH) -iname "$(type)"
 OBJ=$(SOURCE:.py=.pyc)
 BUILD_PATH=./build/
 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
 OBJ=$(SOURCE:.py=.pyc)
 BUILD_PATH=./build/
 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
+TODO_FILE=./TODO
 
 DEBUGGER=winpdb
 UNIT_TEST=nosetests --with-doctest -w .
 
 DEBUGGER=winpdb
 UNIT_TEST=nosetests --with-doctest -w .
@@ -16,9 +17,10 @@ LINT_RC=./support/pylint.rc
 LINT=pylint --rcfile=$(LINT_RC)
 PROFILE_GEN=python -m cProfile -o .profile
 PROFILE_VIEW=python -m pstats .profile
 LINT=pylint --rcfile=$(LINT_RC)
 PROFILE_GEN=python -m cProfile -o .profile
 PROFILE_VIEW=python -m pstats .profile
+TODO_FINDER=support/todo.py
 CTAGS=ctags-exuberant
 
 CTAGS=ctags-exuberant
 
-.PHONY: all run profile debug test lint tags build clean distclean
+.PHONY: all run profile debug test build lint tags todo clean distclean
 
 all: test
 
 
 all: test
 
@@ -54,6 +56,8 @@ lint: $(OBJ)
 
 tags: $(TAG_FILE) 
 
 
 tags: $(TAG_FILE) 
 
+todo: $(TODO_FILE)
+
 clean:
        rm -Rf $(OBJ)
        rm -Rf $(BUILD_PATH)
 clean:
        rm -Rf $(OBJ)
        rm -Rf $(BUILD_PATH)
@@ -71,6 +75,9 @@ $(TAG_FILE): $(OBJ)
        mkdir -p $(dir $(TAG_FILE))
        $(CTAGS) -o $(TAG_FILE) $(SOURCE)
 
        mkdir -p $(dir $(TAG_FILE))
        $(CTAGS) -o $(TAG_FILE) $(SOURCE)
 
+$(TODO_FILE): $(SOURCE)
+       @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
+
 %.pyc: %.py
        $(SYNTAX_TEST) $<
 
 %.pyc: %.py
        $(SYNTAX_TEST) $<
 
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 849daab..0000000
--- a/TODO
+++ /dev/null
@@ -1,25 +0,0 @@
-Ideas
-=================
-User Contacts
-       It seems the evolution contact API used is specific to the desktop.  evolution.ebook combined with abook is what is needed for Maemo.
-       http://maemo.org/maemo_release_documentation/maemo4.1.x/node8.html#SECTION00870000000000000000
-       https://garage.maemo.org/svn/pymaemo/packages/python-abook/trunk/tests/ especially contact_get_iter amd filter_model
-       http://pymaemo.garage.maemo.org/documentation/api/abook/index.html
-
-       Other possible addressbooks
-               GMail http://libgmail.sourceforge.net/
-               GPE
-
-Internet Connection
-       Look into being a bit more advanced, beyond just enabling/disabling the GUI
-       Possible Approach:
-               Defer login
-               While not logged in or device is offline, disable the GUI
-               Don't attempt to login if not online
-
-Notes
-=================
-General Python/Maemo stuff
-       http://pymaemo.garage.maemo.org/documentation.html
-DBus
-       http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
index 4487b66..0c64645 100644 (file)
 
 """
 Evolution Contact Support
 
 """
 Evolution Contact Support
+
+It seems the evolution contact API used is specific to the desktop.  evolution.ebook combined with abook is what is needed for Maemo.
+       http://maemo.org/maemo_release_documentation/maemo4.1.x/node8.html#SECTION00870000000000000000
+       https://garage.maemo.org/svn/pymaemo/packages/python-abook/trunk/tests/ especially contact_get_iter amd filter_model
+       http://pymaemo.garage.maemo.org/documentation/api/abook/index.html
 """
 
 
 """
 
 
diff --git a/support/todo.py b/support/todo.py
new file mode 100755 (executable)
index 0000000..90cbd04
--- /dev/null
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+
+from __future__ import with_statement
+import itertools
+
+
+verbose = False
+
+
+def tag_parser(file, tag):
+       """
+       >>> nothing = []
+       >>> for todo in tag_parser(nothing, "@todo"):
+       ...     print todo
+       ...
+       >>> one = ["@todo Help!"]
+       >>> for todo in tag_parser(one, "@todo"):
+       ...     print todo
+       ...
+       1: @todo Help!
+       >>> mixed = ["one", "@todo two", "three"]
+       >>> for todo in tag_parser(mixed, "@todo"):
+       ...     print todo
+       ...
+       2: @todo two
+       >>> embedded = ["one @todo two", "three"]
+       >>> for todo in tag_parser(embedded, "@todo"):
+       ...     print todo
+       ...
+       1: @todo two
+       >>> continuation = ["one", "@todo two", " three"]
+       >>> for todo in tag_parser(continuation, "@todo"):
+       ...     print todo
+       ...
+       2: @todo two three
+       >>> series = ["one", "@todo two", "@todo three"]
+       >>> for todo in tag_parser(series, "@todo"):
+       ...     print todo
+       ...
+       2: @todo two
+       3: @todo three
+       """
+       currentTodo = []
+       prefix = None
+       for lineNumber, line in enumerate(file):
+               column = line.find(tag)
+               if column != -1:
+                       if currentTodo:
+                               yield "\n".join (currentTodo)
+                       prefix = line[0:column]
+                       currentTodo = ["%d: %s" % (lineNumber+1, line[column:].strip())]
+               elif prefix is not None and len(prefix)+1 < len(line) and line.startswith(prefix) and line[len(prefix)].isspace():
+                       currentTodo.append (line[len(prefix):].rstrip())
+               elif currentTodo:
+                       yield "\n".join (currentTodo)
+                       currentTodo = []
+                       prefix = None
+       if currentTodo:
+               yield "\n".join (currentTodo)
+
+
+def tag_finder(filename, tag):
+       todoList = []
+
+       with open(filename) as file:
+               body = "\n".join (tag_parser(file, tag))
+       passed = not body
+       if passed:
+               output = "No %s's for %s" % (tag, filename) if verbose else ""
+       else:
+               header = "%s's for %s:\n" % (tag, filename) if verbose else ""
+               output = header + body
+               output += "\n" if verbose else ""
+
+       return (passed, output)
+
+
+if __name__ == "__main__":
+       import sys
+       import os
+       import optparse
+
+       opar = optparse.OptionParser()
+       opar.add_option("-v", "--verbose", dest="verbose", help="Toggle verbosity", action="store_true", default=False)
+       options, args = opar.parse_args(sys.argv[1:])
+       verbose = options.verbose
+
+       bugsAsError = True
+       todosAsError = False
+
+       completeOutput = []
+       allPassed = True
+       for filename in args:
+               bugPassed, bugOutput = tag_finder(filename, "@bug")
+               todoPassed, todoOutput = tag_finder(filename, "@todo")
+               output = "\n".join ([bugOutput, todoOutput])
+               if (not bugPassed and bugsAsError) or (not todoPassed and todosAsError):
+                       allPassed = False
+               output = output.strip()
+               if output:
+                       completeOutput.append(filename+":\n"+output+"\n\n")
+       print "\n".join(completeOutput)
+       
+       sys.exit(0 if allPassed else 1);