[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 11ec984620b9ec0f12e0080e0e581c90ca8f92aa
Author: juga0 <juga@xxxxxxxxxx>
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):
         '''



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits