]> granicus.if.org Git - python/commitdiff
Allow open file as parameter (must be seekable) (Jack)
authorGuido van Rossum <guido@python.org>
Wed, 8 Oct 1997 15:22:32 +0000 (15:22 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 8 Oct 1997 15:22:32 +0000 (15:22 +0000)
Lib/imghdr.py

index c320594e97624123af19bdcb1741225938824716..422471fb4467a1416ce7aa687a69f6d260426f1a 100644 (file)
@@ -2,13 +2,19 @@
 
 
 #-------------------------#
-# Recognize sound headers #
+# Recognize image headers #
 #-------------------------#
 
-def what(filename, h=None):
+def what(file, h=None):
        if h is None:
-               f = open(filename, 'r')
-               h = f.read(32)
+               if type(file) == type(''):
+                       f = open(file, 'rb')
+                       h = f.read(32)
+               else:
+                       location = file.tell()
+                       h = file.read(32)
+                       file.seek(location)
+                       f = None        
        else:
                f = None
        try: