Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
671cd329
Kaydet (Commit)
671cd329
authored
Nis 10, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17487: wave.getparams now returns a namedtuple.
Patch by Claudiu Popa.
üst
3f5ffbee
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
8 deletions
+38
-8
wave.rst
Doc/library/wave.rst
+3
-2
3.4.rst
Doc/whatsnew/3.4.rst
+6
-0
test_wave.py
Lib/test/test_wave.py
+16
-0
wave.py
Lib/wave.py
+10
-6
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/wave.rst
Dosyayı görüntüle @
671cd329
...
...
@@ -98,8 +98,9 @@ Wave_read objects, as returned by :func:`.open`, have the following methods:
.. method:: Wave_read.getparams()
Returns a tuple ``(nchannels, sampwidth, framerate, nframes, comptype,
compname)``, equivalent to output of the :meth:`get\*` methods.
Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,
framerate, nframes, comptype, compname)``, equivalent to output of the
:meth:`get\*` methods.
.. method:: Wave_read.readframes(n)
...
...
Doc/whatsnew/3.4.rst
Dosyayı görüntüle @
671cd329
...
...
@@ -157,6 +157,12 @@ doctest
Added ``FAIL_FAST`` flag to halt test running as soon as the first failure is
detected. (Contributed by R. David Murray and Daniel Urban in :issue:`16522`.)
wave
----
The :meth:`~wave.getparams` method now returns a namedtuple rather than a
plain tuple. (Contributed by Claudiu Popa in :issue:`17487`.)
Optimizations
=============
...
...
Lib/test/test_wave.py
Dosyayı görüntüle @
671cd329
...
...
@@ -58,6 +58,22 @@ class TestWave(unittest.TestCase):
output
=
b
'
\0
'
*
nframes
*
nchannels
*
sampwidth
self
.
f
.
writeframes
(
output
)
def
test_getparams
(
self
):
self
.
f
=
wave
.
open
(
TESTFN
,
'wb'
)
self
.
f
.
setnchannels
(
nchannels
)
self
.
f
.
setsampwidth
(
sampwidth
)
self
.
f
.
setframerate
(
framerate
)
self
.
f
.
close
()
self
.
f
=
wave
.
open
(
TESTFN
,
'rb'
)
params
=
self
.
f
.
getparams
()
self
.
assertEqual
(
params
.
nchannels
,
self
.
f
.
getnchannels
())
self
.
assertEqual
(
params
.
nframes
,
self
.
f
.
getnframes
())
self
.
assertEqual
(
params
.
sampwidth
,
self
.
f
.
getsampwidth
())
self
.
assertEqual
(
params
.
framerate
,
self
.
f
.
getframerate
())
self
.
assertEqual
(
params
.
comptype
,
self
.
f
.
getcomptype
())
self
.
assertEqual
(
params
.
compname
,
self
.
f
.
getcompname
())
def
test_main
():
run_unittest
(
TestWave
)
...
...
Lib/wave.py
Dosyayı görüntüle @
671cd329
...
...
@@ -18,7 +18,7 @@ This returns an instance of a class with the following public methods:
getcomptype() -- returns compression type ('NONE' for linear samples)
getcompname() -- returns human-readable version of
compression type ('not compressed' linear samples)
getparams() -- returns a tuple consisting of all of the
getparams() -- returns a
named
tuple consisting of all of the
above in the above order
getmarkers() -- returns None (for compatibility with the
aifc module)
...
...
@@ -90,6 +90,10 @@ else:
big_endian
=
0
from
chunk
import
Chunk
from
collections
import
namedtuple
_result
=
namedtuple
(
'params'
,
'nchannels sampwidth framerate nframes comptype compname'
)
class
Wave_read
:
"""Variables used in this class:
...
...
@@ -206,9 +210,9 @@ class Wave_read:
return
self
.
_compname
def
getparams
(
self
):
return
self
.
getnchannels
(),
self
.
getsampwidth
(),
\
self
.
getframerate
(),
self
.
getnframes
(),
\
self
.
getcomptype
(),
self
.
getcompname
(
)
return
_result
(
self
.
getnchannels
(),
self
.
getsampwidth
(),
self
.
getframerate
(),
self
.
getnframes
(),
self
.
getcomptype
(),
self
.
getcompname
()
)
def
getmarkers
(
self
):
return
None
...
...
@@ -398,8 +402,8 @@ class Wave_write:
def
getparams
(
self
):
if
not
self
.
_nchannels
or
not
self
.
_sampwidth
or
not
self
.
_framerate
:
raise
Error
(
'not all parameters set'
)
return
self
.
_nchannels
,
self
.
_sampwidth
,
self
.
_framerate
,
\
self
.
_nframes
,
self
.
_comptype
,
self
.
_compname
return
_result
(
self
.
_nchannels
,
self
.
_sampwidth
,
self
.
_framerate
,
self
.
_nframes
,
self
.
_comptype
,
self
.
_compname
)
def
setmark
(
self
,
id
,
pos
,
name
):
raise
Error
(
'setmark() not supported'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
671cd329
...
...
@@ -32,6 +32,9 @@ Core and Builtins
Library
-------
-
Issue
#
17487
:
The
wave
getparams
method
now
returns
a
namedtuple
rather
than
a
plain
tuple
.
-
Issue
#
17675
:
socket
repr
()
provides
local
and
remote
addresses
(
if
any
).
Patch
by
Giampaolo
Rodola
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment