commit 9bc81f48061d131e07c14e8c949c24446198d7f8 Author: juga0 juga@riseup.net Date: Fri Aug 31 11:40:10 2018 +0000
Add method to parse V100 file given a path --- sbws/lib/v3bwfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py index 847c037..65a99a8 100644 --- a/sbws/lib/v3bwfile.py +++ b/sbws/lib/v3bwfile.py @@ -450,6 +450,18 @@ class V3BWFile(object): bw_lines = [V3BWLine.from_bw_line_v110(line) for line in lines] return cls(header, bw_lines)
+ @classmethod + def from_v100_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_v100(all_lines) + bw_lines = sorted([V3BWLine.from_bw_line_v110(l) for l in lines], + key=lambda l: l.bw) + return cls(header, bw_lines) + + @staticmethod def bw_kb(bw_lines, reverse=False): bw_lines_scaled = copy.deepcopy(bw_lines)