commit 39219fc2d1d18cf1457cf7a9eddd6daefc1e6c17 Author: juga0 juga@riseup.net Date: Fri Aug 31 11:38:01 2018 +0000
Add method to parse V110 file from a given path --- sbws/lib/v3bwfile.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py index 34866e9..dda4499 100644 --- a/sbws/lib/v3bwfile.py +++ b/sbws/lib/v3bwfile.py @@ -429,6 +429,16 @@ class V3BWFile(object): f = cls(header, bw_lines) return f
+ @classmethod + def from_v110_fpath(cls, fpath): + log.info('Parsing bandwidth file %s', fpath) + with open(fpath) as fd: + text = fd.read() + all_lines = text.split(LINE_SEP) + header, lines = V3BWHeader.from_lines_v110(all_lines) + bw_lines = [V3BWLine.from_bw_line_v110(line) for line in lines] + return cls(header, bw_lines) + @staticmethod def bw_kb(bw_lines, reverse=False): bw_lines_scaled = copy.deepcopy(bw_lines)