From 29e5f810784828457ddc19cc721bd9039f729be4 Mon Sep 17 00:00:00 2001 From: Matthew Stidham Date: Mon, 6 Dec 2021 11:32:06 -0800 Subject: [PATCH] GhostRequest: Use staticmethod where relevant Signed-off-by: Matthew Stidham --- py-dashboard/GhostRequest.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/py-dashboard/GhostRequest.py b/py-dashboard/GhostRequest.py index ce0dc586..b46329df 100644 --- a/py-dashboard/GhostRequest.py +++ b/py-dashboard/GhostRequest.py @@ -29,8 +29,8 @@ RecordInflux = InfluxRequest.RecordInflux class CSVReader: - def read_csv(self, - file, + @staticmethod + def read_csv(file, sep='\t'): df = open(file).read().split('\n') rows = list() @@ -39,8 +39,8 @@ class CSVReader: rows.append(x.split(sep)) return rows - def get_column(self, - df, + @staticmethod + def get_column(df, value): index = df[0].index(value) values = [] @@ -48,7 +48,8 @@ class CSVReader: values.append(row[index]) return values - def get_columns(self, df, targets): + @staticmethod + def get_columns(df, targets): target_index = [] for item in targets: target_index.append(df[0].index(item)) @@ -60,7 +61,8 @@ class CSVReader: results.append(row_data) return results - def to_html(self, df): + @staticmethod + def to_html(df): html = '' html = html + ('' '' @@ -78,7 +80,8 @@ class CSVReader: '
') return html - def filter_df(self, df, column, expression, target): + @staticmethod + def filter_df(df, column, expression, target): target_index = df[0].index(column) counter = 0 targets = [0] @@ -98,7 +101,8 @@ class CSVReader: counter += 1 return list(map(df.__getitem__, targets)) - def concat(self, dfs): + @staticmethod + def concat(dfs): return list(itertools.chain.from_iterable(dfs))