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.
|
||||
print "<tasks>"
|
||||
for task in commands.getoutput (command).split (",\n"):
|
||||
data = json.loads (task)
|
||||
print " <task>"
|
||||
for attribute in data.items ():
|
||||
if attribute[0] == "annotations":
|
||||
print " <annotations>"
|
||||
for anno in attribute[1]:
|
||||
print " <annotation>"
|
||||
for item in anno.items ():
|
||||
print " <{0}>{1}</{0}>".format (item[0], item[1])
|
||||
print " </annotation>"
|
||||
print " </annotations>"
|
||||
elif attribute[0] == "tags":
|
||||
print " <tags>"
|
||||
for tag in attribute[1]:
|
||||
print " <tag>{0}</tag>".format (tag)
|
||||
print " </tags>"
|
||||
else:
|
||||
print " <{0}>{1}</{0}>".format (attribute[0], attribute[1])
|
||||
print " </task>"
|
||||
print "</tasks>"
|
||||
data = json.loads (task)
|
||||
print (" <task>")
|
||||
for name,value in data.items ():
|
||||
if name == "annotations":
|
||||
print (" <annotations>")
|
||||
for anno in value:
|
||||
print (" <annotation>")
|
||||
for name,value in anno.items ():
|
||||
print (" <{0}>{1}</{0}>".format (name, value))
|
||||
print (" </annotation>")
|
||||
print (" </annotations>")
|
||||
elif name == "tags":
|
||||
print (" <tags>")
|
||||
for tag in value:
|
||||
print (" <tag>{0}</tag>".format (tag))
|
||||
print (" </tags>")
|
||||
else:
|
||||
print (" <{0}>{1}</{0}>".format (name, value))
|
||||
print (" </task>")
|
||||
print ("</tasks>")
|
||||
sys.exit (0)
|
||||
|
||||
################################################################################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue