Merge "Rebuild odex files in PDK fusion build."
diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py
index 975a48a..31ed83a 100644
--- a/tools/releasetools/rangelib.py
+++ b/tools/releasetools/rangelib.py
@@ -71,6 +71,19 @@
"""
return cls(text)
+ @classmethod
+ def parse_raw(cls, text):
+ """Parse a string generated by RangeSet.to_string_raw().
+
+ >>> RangeSet.parse_raw(RangeSet("0-9").to_string_raw())
+ <RangeSet("0-9")>
+ """
+
+ raw = [int(i) for i in text.split(',')]
+ assert raw[0] == len(raw[1:]), "Invalid raw string."
+
+ return cls(data=raw[1:])
+
def _parse_internal(self, text):
data = []
last = -1
diff --git a/tools/releasetools/test_rangelib.py b/tools/releasetools/test_rangelib.py
index 7debe66..853012e 100644
--- a/tools/releasetools/test_rangelib.py
+++ b/tools/releasetools/test_rangelib.py
@@ -123,3 +123,17 @@
self.assertTrue(RangeSet(data=[2, 9, 30, 31, 31, 32, 35, 36]).monotonic)
self.assertTrue(RangeSet(data=[0, 5, 5, 10]).monotonic)
self.assertFalse(RangeSet(data=[5, 10, 0, 5]).monotonic)
+
+ def test_parse_raw(self):
+ self.assertEqual(
+ RangeSet.parse_raw(RangeSet("0-9").to_string_raw()),
+ RangeSet("0-9"))
+ self.assertEqual(RangeSet.parse_raw(
+ RangeSet("2-10 12").to_string_raw()),
+ RangeSet("2-10 12"))
+ self.assertEqual(
+ RangeSet.parse_raw(RangeSet("11 2-10 12 1 0").to_string_raw()),
+ RangeSet("11 2-10 12 1 0"))
+
+ with self.assertRaises(AssertionError):
+ RangeSet.parse_raw("4,0,10")