update for python 3
This commit is contained in:
@@ -51,18 +51,18 @@ __history__ = """
|
||||
"""
|
||||
|
||||
def usage():
|
||||
print "USAGE: %s [todo.txt] [done.txt]" % (sys.argv[0], )
|
||||
print("USAGE: %s [todo.txt] [done.txt]" % (sys.argv[0], ))
|
||||
|
||||
def printTaskGroups(title, taskDict, priorityList, percentages):
|
||||
print ""
|
||||
print "%s"% (title,)
|
||||
print("")
|
||||
print("%s"% (title,))
|
||||
separator("-")
|
||||
if not taskDict:
|
||||
print "No items to list."
|
||||
print("No items to list.")
|
||||
else:
|
||||
# sort the dictionary by value
|
||||
# http://python.fyxm.net/peps/pep-0265.html
|
||||
items = [(v, k) for k, v in taskDict.items()]
|
||||
items = [(v, k) for k, v in list(taskDict.items())]
|
||||
items.sort()
|
||||
items.reverse() # so largest is first
|
||||
items = [(k, v) for v, k in items]
|
||||
@@ -84,7 +84,7 @@ def printTaskGroups(title, taskDict, priorityList, percentages):
|
||||
def printTaskGroup(p, pctage, star):
|
||||
if pctage > -1:
|
||||
progressBar = ""
|
||||
numStars = (pctage/10)
|
||||
numStars = int(pctage//10)
|
||||
progressBar = "=" * numStars
|
||||
numSpaces = 10 - numStars
|
||||
for n in range(numSpaces):
|
||||
@@ -94,14 +94,14 @@ def printTaskGroup(p, pctage, star):
|
||||
displayTotal = " %d%%"% (pctage, );
|
||||
else:
|
||||
displayTotal = " %d%%"% (pctage, );
|
||||
print "%s %s [%s] %s (%d todo's)"% (star, displayTotal, progressBar, p[0], p[1],)
|
||||
print("%s %s [%s] %s (%d todo's)"% (star, displayTotal, progressBar, p[0], p[1],))
|
||||
else:
|
||||
print "%s %s (%d todo's)"% (star, p[0], p[1], )
|
||||
print("%s %s (%d todo's)"% (star, p[0], p[1], ))
|
||||
|
||||
def separator(c):
|
||||
sep = ""
|
||||
sep = c * 42
|
||||
print sep
|
||||
print(sep)
|
||||
|
||||
|
||||
def main(argv):
|
||||
@@ -139,7 +139,7 @@ def main(argv):
|
||||
contextPriority.append(word)
|
||||
f.close()
|
||||
except IOError:
|
||||
print "ERROR: The file named %s could not be read."% (argv[0], )
|
||||
print("ERROR: The file named %s could not be read."% (argv[0], ))
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
@@ -157,7 +157,7 @@ def main(argv):
|
||||
completedTasks[word] = completedTasks.setdefault(word, 0) + 1
|
||||
f.close()
|
||||
except IOError:
|
||||
print "ERROR: The file named %s could not be read."% (argv[1], )
|
||||
print("ERROR: The file named %s could not be read."% (argv[1], ))
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
@@ -180,18 +180,18 @@ def main(argv):
|
||||
|
||||
# print out useful info
|
||||
#print "TODO.TXT Bird's Eye View Report %s"% ( datetime.date.today().isoformat(), )
|
||||
print ""
|
||||
print "TODO.TXT Bird's Eye View Report"
|
||||
print("")
|
||||
print("TODO.TXT Bird's Eye View Report")
|
||||
|
||||
separator("=")
|
||||
|
||||
printTaskGroups("Projects with Open TODO's", projects, projectPriority, projectPercentages)
|
||||
printTaskGroups("Contexts with Open TODO's", contexts, contextPriority, projectPercentages)
|
||||
printTaskGroups("Completed Projects (No open TODO's)", projectsWithNoIncompletes, projectPriority, projectPercentages)
|
||||
print ""
|
||||
print "* Projects and contexts with an asterisk next to them denote prioritized tasks."
|
||||
print "Project with prioritized tasks are listed first, then sorted by number of open todo's."
|
||||
print ""
|
||||
print("")
|
||||
print("* Projects and contexts with an asterisk next to them denote prioritized tasks.")
|
||||
print("Project with prioritized tasks are listed first, then sorted by number of open todo's.")
|
||||
print("")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user