[tor-commits] [sbws/master] Add method to parse a V100 header

juga at torproject.org juga at torproject.org
Tue Sep 18 09:26:11 UTC 2018


commit 11ec984620b9ec0f12e0080e0e581c90ca8f92aa
Author: juga0 <juga at riseup.net>
Date:   Fri Aug 31 11:39:31 2018 +0000

    Add method to parse a V100 header
---
 sbws/lib/v3bwfile.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index dda4499..847c037 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -139,6 +139,17 @@ class V3BWHeader(object):
         assert isinstance(text, str)
         return self.from_lines_v110(text.split(LINE_SEP))
 
+    @classmethod
+    def from_lines_v100(cls, lines):
+        """
+        :param list lines: list of lines to parse
+        :returns: tuple of V3BWHeader object and non-header lines
+        """
+        assert isinstance(lines, list)
+        h = cls(lines[0])
+        # last line is new line
+        return h, lines[1:-1]
+
     @staticmethod
     def generator_started_from_file(state_fpath):
         '''





More information about the tor-commits mailing list