From 5b3ba7911d0d2c64da59c5020f9307c1222edc58 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 13 Feb 2019 10:39:42 +0900 Subject: view: add get_data() To support relationships, directly getting Yaml data on each function is more useful. Let's add get_data() and do it. Signed-off-by: Kuninori Morimoto --- scripts/view.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/view.py b/scripts/view.py index b73095c..04928e1 100755 --- a/scripts/view.py +++ b/scripts/view.py @@ -48,11 +48,22 @@ class viewer(base.base): self.parse(arg) + #-------------------- + # get_data + #-------------------- + def get_data(self, file): + F = open(file, "r+") + data = yaml.load(F) + F.close() + return data + #-------------------- # make_one # for --oneline #-------------------- - def make_one(self, file, data): + def make_one(self, file): + + data = self.get_data(file) if (len(self.text) > 0): self.text += "\n" @@ -66,7 +77,9 @@ class viewer(base.base): # make_full # for normal #-------------------- - def make_full(self, file, data): + def make_full(self, file): + + data = self.get_data(file) if (len(self.text) > 0): self.text += "\n" @@ -98,14 +111,10 @@ class viewer(base.base): #-------------------- def show(self): for f in self.files: - F = open(f, "r+") - data = yaml.load(F) - F.close() - if (self.one_line): - self.make_one(f, data) + self.make_one(f) else: - self.make_full(f, data) + self.make_full(f) # escape " -> \" # otherwise " will be disappeared -- cgit v1.2.3