From 3c3c07d7de2ddeabc07d34d0eb197a88bd8551e0 Mon Sep 17 00:00:00 2001 From: chenhq Date: Tue, 19 Sep 2023 11:03:04 +0800 Subject: [PATCH] optimize #221 --- solox/public/common.py | 12 ++++++++---- solox/templates/analysis.html | 36 ----------------------------------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/solox/public/common.py b/solox/public/common.py index a7f16e2..7f6f9e8 100644 --- a/solox/public/common.py +++ b/solox/public/common.py @@ -385,14 +385,18 @@ def instance_type(self, data): return 'int' else: return 'int' + + def open_file(self, path, mode): + with open(path, mode) as f: + for line in f: + yield line def readLog(self, scene, filename): """Read apmlog file data""" - log_data_list = [] - target_data_list = [] + log_data_list = list() + target_data_list = list() if os.path.exists(os.path.join(self.report_dir,scene,filename)): - f = open(os.path.join(self.report_dir,scene,filename), "r") - lines = f.readlines() + lines = self.open_file(os.path.join(self.report_dir,scene,filename), "r") for line in lines: if isinstance(line.split('=')[1].strip(), int): log_data_list.append({ diff --git a/solox/templates/analysis.html b/solox/templates/analysis.html index c809e9b..6884694 100644 --- a/solox/templates/analysis.html +++ b/solox/templates/analysis.html @@ -730,12 +730,6 @@