Revision: 4278
Author: janne.t.harkonen
Date: Wed Nov  3 06:19:07 2010
Log: implemented Get Binary File, issue 698
http://code.google.com/p/robotframework/source/detail?r=4278

Modified:
 /trunk/src/robot/libraries/OperatingSystem.py

=======================================
--- /trunk/src/robot/libraries/OperatingSystem.py       Fri Sep 24 05:34:09 2010
+++ /trunk/src/robot/libraries/OperatingSystem.py       Wed Nov  3 06:19:07 2010
@@ -287,12 +287,17 @@
         'UTF-8', which means that UTF-8 and ASCII-encoded files are read
         correctly.
         """
+        content = self.get_binary_file(path)
+        return unicode(content, encoding).replace('\r\n', '\n')
+
+    def get_binary_file(self, path):
         path = self._absnorm(path)
         self._link("Getting file '%s'", path)
         f = open(path, 'rb')
-        content = f.read()
-        f.close()
-        return unicode(content, encoding).replace('\r\n', '\n')
+        try:
+            return f.read()
+        finally:
+            f.close()

     def grep_file(self, path, pattern, encoding='UTF-8'):
"""Returns the lines of the specified file that match the `pattern`.

Reply via email to