[ARVADOS] updated: 43e09c03c00f14d923f7335aa3d632d7e4785fbb

git at public.curoverse.com git at public.curoverse.com
Sun Feb 16 22:21:05 EST 2014


Summary of changes:
 sdk/python/arvados/stream.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

       via  43e09c03c00f14d923f7335aa3d632d7e4785fbb (commit)
      from  fa739e32888d42bb99cef4781dc0c3f1c6190ac7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 43e09c03c00f14d923f7335aa3d632d7e4785fbb
Author: Peter Amstutz <tetron at cosmos>
Date:   Sun Feb 16 22:21:31 2014 -0500

    Added readfrom()

diff --git a/sdk/python/arvados/stream.py b/sdk/python/arvados/stream.py
index 7dd5736..ac91e2a 100644
--- a/sdk/python/arvados/stream.py
+++ b/sdk/python/arvados/stream.py
@@ -129,6 +129,16 @@ class StreamFileReader(object):
             self._filepos += len(data)
         return data
 
+    def readfrom(self, start, size):
+        """Read up to 'size' bytes from the stream, starting at 'start'"""
+        if size == 0:
+            return ''
+
+        data = []
+        for locator, blocksize, segmentoffset, segmentsize in locators_and_ranges(self.segments, start, size):
+            data += self._stream.readfrom(locator+segmentoffset, segmentsize)
+        return data.join()
+
     def readall(self, size=2**20):
         while True:
             data = self.read(size)
@@ -249,3 +259,12 @@ class StreamReader(object):
             data += Keep.get(locator)[segmentoffset:segmentoffset+segmentsize]
         self._pos += len(data)
         return data
+
+    def readfrom(self, start, size):
+        """Read up to 'size' bytes from the stream, starting at 'start'"""
+        if size == 0:
+            return ''
+        data = ''
+        for locator, blocksize, segmentoffset, segmentsize in locators_and_ranges(self.data_locators, start, size):
+            data += Keep.get(locator)[segmentoffset:segmentoffset+segmentsize]
+        return data

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list