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:
@@ -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)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user