diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-02-25 15:53:37 +0900 |
---|---|---|
committer | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-04-09 14:59:34 +0900 |
commit | 39f25bf805115fabba4290328492aa23db0d7013 (patch) | |
tree | 3f99955fe20af966e1b846bf8e6ef9ed36d13c66 | |
parent | 7b826ee9948ade695d86a78f659494b40731067e (diff) |
view: add set_data/get_data
To be more object, let's add set_data/get_data
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
-rwxr-xr-x | scripts/view.py | 40 |
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()), |