mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Review
- Incorporated (most of the) feedback from John's review of the code. Got stuck on replacing 'import commands' with 'import subprocess', and all that entails.
This commit is contained in:
parent
eee4d05b77
commit
c963fd30ba
1 changed files with 20 additions and 20 deletions
|
@ -36,26 +36,26 @@ command = "/usr/local/bin/task _query " + " ".join (sys.argv[1:])
|
||||||
# Generate output.
|
# Generate output.
|
||||||
print "<tasks>"
|
print "<tasks>"
|
||||||
for task in commands.getoutput (command).split (",\n"):
|
for task in commands.getoutput (command).split (",\n"):
|
||||||
data = json.loads (task)
|
data = json.loads (task)
|
||||||
print " <task>"
|
print (" <task>")
|
||||||
for attribute in data.items ():
|
for name,value in data.items ():
|
||||||
if attribute[0] == "annotations":
|
if name == "annotations":
|
||||||
print " <annotations>"
|
print (" <annotations>")
|
||||||
for anno in attribute[1]:
|
for anno in value:
|
||||||
print " <annotation>"
|
print (" <annotation>")
|
||||||
for item in anno.items ():
|
for name,value in anno.items ():
|
||||||
print " <{0}>{1}</{0}>".format (item[0], item[1])
|
print (" <{0}>{1}</{0}>".format (name, value))
|
||||||
print " </annotation>"
|
print (" </annotation>")
|
||||||
print " </annotations>"
|
print (" </annotations>")
|
||||||
elif attribute[0] == "tags":
|
elif name == "tags":
|
||||||
print " <tags>"
|
print (" <tags>")
|
||||||
for tag in attribute[1]:
|
for tag in value:
|
||||||
print " <tag>{0}</tag>".format (tag)
|
print (" <tag>{0}</tag>".format (tag))
|
||||||
print " </tags>"
|
print (" </tags>")
|
||||||
else:
|
else:
|
||||||
print " <{0}>{1}</{0}>".format (attribute[0], attribute[1])
|
print (" <{0}>{1}</{0}>".format (name, value))
|
||||||
print " </task>"
|
print (" </task>")
|
||||||
print "</tasks>"
|
print ("</tasks>")
|
||||||
sys.exit (0)
|
sys.exit (0)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue