summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/view.py40
1 files changed, 25 insertions, 15 deletions
diff --git a/scripts/view.py b/scripts/view.py
index 308d1db..9486e51 100755
--- a/scripts/view.py
+++ b/scripts/view.py
@@ -51,6 +51,8 @@ class viewer(base.base):
self.one_line = 0
self.parse(arg)
+ self.data = {}
+ self.file = ""
#--------------------
# get_item
@@ -73,13 +75,21 @@ class viewer(base.base):
return data
#--------------------
+ # set_data
# get_data
#--------------------
- def get_data(self, file):
+ def set_data(self, file):
F = open(file, "r+")
- data = yaml.load(F)
+ self.data = yaml.load(F)
F.close()
- return data
+ self.file = file
+
+ def get_data(self, key):
+ data = self.data[key]
+ if (data):
+ return data
+ else:
+ return []
#--------------------
# make_one
@@ -97,15 +107,15 @@ class viewer(base.base):
self.text += self.color("error", "No such task ({})".format(file))
return
- data = self.get_data(file)
+ self.set_data(file)
# show "key"
self.text += "{}: {}".format(
- self.color("key", data["key"]),
- data["title"])
+ self.color("key", self.get_data("key")),
+ self.get_data("title"))
# show relationships
- relationships = data["relationships"]
+ relationships = self.get_data("relationships")
if ((not tag) and self.with_rel and relationships):
for d in relationships:
self.make_one(self.get_item(d.keys()),
@@ -127,32 +137,32 @@ class viewer(base.base):
self.text += self.color("error", "No such task ({})".format(file))
return
- data = self.get_data(file)
+ self.set_data(file)
# show "key"
self.text += "{}, {}, {}\n".format(
- self.color("key", data["key"]),
- self.color("status", data["status"]),
- self.color("team", data["team"]));
+ self.color("key", self.get_data("key")),
+ self.color("status", self.get_data("status")),
+ self.color("team", self.get_data("team")));
# show title
- self.text += "Title: {}\n".format(data["title"])
+ self.text += "Title: {}\n".format(self.get_data("title"))
# show assignee
- self.text += "Assignee: {}\n".format(data["assignee"])
+ self.text += "Assignee: {}\n".format(self.get_data("assignee"))
if (self.with_file):
self.text += "File: {}\n".format(
os.path.abspath(file).replace("{}/".format(self.top()), ""))
# show comments
- comments = data["comments"]
+ comments = self.get_data("comments")
if (comments):
for comment in comments:
self.text += "\n{}".format(comment)
# show relationships
- relationships = data["relationships"]
+ relationships = self.get_data("relationships")
if ((not tag) and self.with_rel and relationships):
for d in relationships:
self.make_full(self.get_item(d.keys()),