mirror of https://github.com/python/cpython
Added optional second arg to what(), giving the data read from the file
(then f may be None).
This commit is contained in:
parent
56a733856e
commit
81749b0754
|
@ -5,13 +5,19 @@
|
||||||
# Recognize sound headers #
|
# Recognize sound headers #
|
||||||
#-------------------------#
|
#-------------------------#
|
||||||
|
|
||||||
def what(filename):
|
def what(filename, h=None):
|
||||||
f = open(filename, 'r')
|
if not h:
|
||||||
h = f.read(32)
|
f = open(filename, 'r')
|
||||||
for tf in tests:
|
h = f.read(32)
|
||||||
res = tf(h, f)
|
else:
|
||||||
if res:
|
f = None
|
||||||
return res
|
try:
|
||||||
|
for tf in tests:
|
||||||
|
res = tf(h, f)
|
||||||
|
if res:
|
||||||
|
return res
|
||||||
|
finally:
|
||||||
|
if f: f.close()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue