Commits

Philippe Lagadec committed 1213645

version 0.20 2009-12-11

Comments (0)

Files changed (1)

OleFileIO_PL/OleFileIO_PL.py

     Microsoft Compound Document File Format), such as Microsoft Office
     documents, Image Composer and FlashPix files, Outlook messages, ...
 
-version 0.19 2009-12-10 Philippe Lagadec - http://www.decalage.info
+version 0.20 2009-12-11 Philippe Lagadec - http://www.decalage.info
 
 Project website: http://www.decalage.info/python/olefileio
 
 """
 
 __author__  = "Fredrik Lundh (Secret Labs AB), Philippe Lagadec"
-__date__    = "2009-12-10"
-__version__ = '0.19'
+__date__    = "2009-12-11"
+__version__ = '0.20'
 
 #--- LICENSE ------------------------------------------------------------------
 
 #                      - added option '-c' in main to check all streams
 # 2009-12-10 v0.19 PL: - bugfix for 32 bit arrays on 64 bits platforms
 #                        (thanks to Ben G. and Martijn for reporting the bug)
+# 2009-12-11 v0.20 PL: - bugfix in OleFileIO.open when filename is not plain str
 
 #-----------------------------------------------------------------------------
 # TODO (for version 1.0):
         """
         Open an OLE2 file.
         Reads the header, FAT and directory.
+
+        filename: string-like or file-like object
         """
-        if type(filename) == type(""):
+        #[PL] check if filename is a string-like or file-like object:
+        # (it is better to check for a read() method)
+        if hasattr(filename, 'read'):
+            # file-like object
+            self.fp = filename
+        else:
+            # string-like object
             self.fp = open(filename, "rb")
-        else:
-            self.fp = filename
+        # old code fails if filename is not a plain string:
+        #if type(filename) == type(""):
+        #    self.fp = open(filename, "rb")
+        #else:
+        #    self.fp = filename
 
         # lists of streams in FAT and MiniFAT, to detect duplicate references
         # (list of indexes of first sectors of each stream)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.