TransRead: allow reading entire file
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 6 May 2013 12:13:49 +0000 (15:13 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 6 May 2013 14:58:51 +0000 (17:58 +0300)
The 'read()' method of python file objects does not require the user specifying
the size, and allows for negative size as well. In this case it just reads
entire file. Ament TransRead to also follow this convention.

Change-Id: I3c0c645d458654711f3dc7a832aaec427d4abd00
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptools/TransRead.py

index 834f6c17b1251e77a5b69adab2fe492bb53a76e0..fd184dac6096cb73c089d96ab43c5c1cb6ec383e 100644 (file)
@@ -266,10 +266,13 @@ class TransRead:
 
         self._open_compressed_file()
 
-    def read(self, size):
+    def read(self, size = -1):
         """ Read the data from the file or URL and and uncompress it on-the-fly
         if necessary. """
 
+        if size < 0:
+            size = 0xFFFFFFFFFFFFFFFF
+
         buf = self._transfile_obj.read(size)
         self._pos += len(buf)