[ARVADOS] updated: c39ba5193005a4e9f619901f8348f11fada88df0

Git user git at public.curoverse.com
Thu Apr 20 14:15:57 EDT 2017


Summary of changes:
 sdk/python/arvados/arvfile.py    | 19 ++++++++++++++++---
 sdk/python/tests/test_arvfile.py |  6 +++---
 2 files changed, 19 insertions(+), 6 deletions(-)

       via  c39ba5193005a4e9f619901f8348f11fada88df0 (commit)
      from  5180238a10bd15302a1c15b9a428f2fdeeabdf4e (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 c39ba5193005a4e9f619901f8348f11fada88df0
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Apr 20 14:15:49 2017 -0400

    11510: Tweak interface to better match Pythons "io.IOBase" class.

diff --git a/sdk/python/arvados/arvfile.py b/sdk/python/arvados/arvfile.py
index cd70c02..aad3ce1 100644
--- a/sdk/python/arvados/arvfile.py
+++ b/sdk/python/arvados/arvfile.py
@@ -99,10 +99,20 @@ class ArvadosFileReaderBase(_FileLikeObjectBase):
         if pos < 0L:
             raise IOError(errno.EINVAL, "Tried to seek to negative file offset.")
         self._filepos = pos
+        return self._filepos
 
     def tell(self):
         return self._filepos
 
+    def readable(self):
+        return True
+
+    def writable(self):
+        return False
+
+    def seekable(self):
+        return True
+
     @_FileLikeObjectBase._before_close
     @retry_method
     def readall(self, size=2**20, num_retries=None):
@@ -174,13 +184,13 @@ class ArvadosFileReaderBase(_FileLikeObjectBase):
         return ''.join(data).splitlines(True)
 
     def size(self):
-        raise NotImplementedError()
+        raise IOError(errno.ENOSYS, "Not implemented")
 
     def read(self, size, num_retries=None):
-        raise NotImplementedError()
+        raise IOError(errno.ENOSYS, "Not implemented")
 
     def readfrom(self, start, size, num_retries=None):
-        raise NotImplementedError()
+        raise IOError(errno.ENOSYS, "Not implemented")
 
 
 class StreamFileReader(ArvadosFileReaderBase):
@@ -1217,6 +1227,9 @@ class ArvadosFileWriter(ArvadosFileReader):
         self.mode = mode
         self.arvadosfile.add_writer(self)
 
+    def writable(self):
+        return True
+
     @_FileLikeObjectBase._before_close
     @retry_method
     def write(self, data, num_retries=None):
diff --git a/sdk/python/tests/test_arvfile.py b/sdk/python/tests/test_arvfile.py
index d45e4d4..20b2584 100644
--- a/sdk/python/tests/test_arvfile.py
+++ b/sdk/python/tests/test_arvfile.py
@@ -142,8 +142,8 @@ class ArvadosFileWriterTestCase(unittest.TestCase):
             self.assertEqual("", writer.read(12))
 
             self.assertEqual(writer.size(), 8)
-            writer.seek(-12, os.SEEK_CUR)
-            self.assertEqual("01234567", writer.read(12))
+            self.assertEqual(2, writer.seek(-10, os.SEEK_CUR))
+            self.assertEqual("234567", writer.read(12))
 
             self.assertIsNone(c.manifest_locator())
             self.assertTrue(c.modified())
@@ -166,7 +166,7 @@ class ArvadosFileWriterTestCase(unittest.TestCase):
             writer = c.open("count.txt", "r+")
             self.assertEqual(writer.size(), 10)
 
-            writer.seek(5, os.SEEK_SET)
+            self.assertEqual(5, writer.seek(5, os.SEEK_SET))
             self.assertEqual("56789", writer.read(8))
 
             writer.seek(10, os.SEEK_SET)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list