mirror of https://github.com/python/cpython
Allow open file as parameter (must be seekable) (Jack)
This commit is contained in:
parent
845037018d
commit
45ac47c0b2
|
@ -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')
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue