#18615: Make sndhdr return namedtuples.

Patch by Claudiu Popa.
This commit is contained in:
R David Murray 2014-10-09 16:59:30 -04:00
parent aad627f2f9
commit 4487dd0ed5
5 changed files with 39 additions and 5 deletions

View file

@ -32,6 +32,11 @@ explicitly given directories.
__all__ = ['what', 'whathdr']
from collections import namedtuple
SndHeaders = namedtuple('SndHeaders',
'filetype framerate nchannels nframes sampwidth')
def what(filename):
"""Guess the type of a sound file."""
res = whathdr(filename)
@ -45,7 +50,7 @@ def whathdr(filename):
for tf in tests:
res = tf(h, f)
if res:
return res
return SndHeaders(*res)
return None