summaryrefslogtreecommitdiff
path: root/Lib/sunau.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-09-04 00:43:03 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2013-09-04 00:43:03 +0300
commit94caa2f71d34ea35b6075d2b6d5f8dadd8b691ab (patch)
tree02a2c6c1ae50ccd42f12905003db6b458454e697 /Lib/sunau.py
parent9a9dd11d38e6a7cd46d648b8144178a3bdcad1ed (diff)
downloadcpython-94caa2f71d34ea35b6075d2b6d5f8dadd8b691ab.tar.gz
Issue #18901: The sunau getparams method now returns a namedtuple rather than
a plain tuple. Patch by Claudiu Popa.
Diffstat (limited to 'Lib/sunau.py')
-rw-r--r--Lib/sunau.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 6775a53cf7..7d7cd6c688 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -51,7 +51,7 @@ This returns an instance of a class with the following public methods:
getcomptype() -- returns compression type ('NONE' or 'ULAW')
getcompname() -- returns human-readable version of
compression type ('not compressed' matches 'NONE')
- getparams() -- returns a tuple consisting of all of the
+ getparams() -- returns a namedtuple consisting of all of the
above in the above order
getmarkers() -- returns None (for compatibility with the
aifc module)
@@ -103,6 +103,11 @@ The close() method is called automatically when the class instance
is destroyed.
"""
+from collections import namedtuple
+
+_sunau_params = namedtuple('_sunau_params',
+ 'nchannels sampwidth framerate nframes comptype compname')
+
# from <multimedia/audio_filehdr.h>
AUDIO_FILE_MAGIC = 0x2e736e64
AUDIO_FILE_ENCODING_MULAW_8 = 1
@@ -242,9 +247,9 @@ class Au_read:
return 'not compressed'
def getparams(self):
- return self.getnchannels(), self.getsampwidth(), \
- self.getframerate(), self.getnframes(), \
- self.getcomptype(), self.getcompname()
+ return _sunau_params(self.getnchannels(), self.getsampwidth(),
+ self.getframerate(), self.getnframes(),
+ self.getcomptype(), self.getcompname())
def getmarkers(self):
return None
@@ -381,9 +386,9 @@ class Au_write:
self.setcomptype(comptype, compname)
def getparams(self):
- return self.getnchannels(), self.getsampwidth(), \
- self.getframerate(), self.getnframes(), \
- self.getcomptype(), self.getcompname()
+ return _sunau_getparams(self.getnchannels(), self.getsampwidth(),
+ self.getframerate(), self.getnframes(),
+ self.getcomptype(), self.getcompname())
def tell(self):
return self._nframeswritten