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
e06a8965
Kaydet (Commit)
e06a8965
authored
Eyl 03, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18901: The sunau getparams method now returns a namedtuple rather than
a plain tuple. Patch by Claudiu Popa.
üst
4c6a020a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
9 deletions
+47
-9
sunau.rst
Doc/library/sunau.rst
+3
-2
3.4.rst
Doc/whatsnew/3.4.rst
+7
-0
sunau.py
Lib/sunau.py
+12
-7
test_sunau.py
Lib/test/test_sunau.py
+22
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/sunau.rst
Dosyayı görüntüle @
e06a8965
...
@@ -150,8 +150,9 @@ AU_read objects, as returned by :func:`.open` above, have the following methods:
...
@@ -150,8 +150,9 @@ AU_read objects, as returned by :func:`.open` above, have the following methods:
.. method:: AU_read.getparams()
.. method:: AU_read.getparams()
Returns a tuple ``(nchannels, sampwidth, framerate, nframes, comptype,
Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,
compname)``, equivalent to output of the :meth:`get\*` methods.
framerate, nframes, comptype, compname)``, equivalent to output of the
:meth:`get\*` methods.
.. method:: AU_read.readframes(n)
.. method:: AU_read.readframes(n)
...
...
Doc/whatsnew/3.4.rst
Dosyayı görüntüle @
e06a8965
...
@@ -365,6 +365,13 @@ Streaming struct unpacking using :func:`struct.iter_unpack`.
...
@@ -365,6 +365,13 @@ Streaming struct unpacking using :func:`struct.iter_unpack`.
(Contributed by Antoine Pitrou in :issue:`17804`.)
(Contributed by Antoine Pitrou in :issue:`17804`.)
sunau
-----
The :meth:`~sunau.getparams` method now returns a namedtuple rather than a
plain tuple. (Contributed by Claudiu Popa in :issue:`18901`.)
urllib
urllib
------
------
...
...
Lib/sunau.py
Dosyayı görüntüle @
e06a8965
...
@@ -51,7 +51,7 @@ This returns an instance of a class with the following public methods:
...
@@ -51,7 +51,7 @@ This returns an instance of a class with the following public methods:
getcomptype() -- returns compression type ('NONE' or 'ULAW')
getcomptype() -- returns compression type ('NONE' or 'ULAW')
getcompname() -- returns human-readable version of
getcompname() -- returns human-readable version of
compression type ('not compressed' matches 'NONE')
compression type ('not compressed' matches 'NONE')
getparams() -- returns a tuple consisting of all of the
getparams() -- returns a
named
tuple consisting of all of the
above in the above order
above in the above order
getmarkers() -- returns None (for compatibility with the
getmarkers() -- returns None (for compatibility with the
aifc module)
aifc module)
...
@@ -103,6 +103,11 @@ The close() method is called automatically when the class instance
...
@@ -103,6 +103,11 @@ The close() method is called automatically when the class instance
is destroyed.
is destroyed.
"""
"""
from
collections
import
namedtuple
_sunau_params
=
namedtuple
(
'_sunau_params'
,
'nchannels sampwidth framerate nframes comptype compname'
)
# from <multimedia/audio_filehdr.h>
# from <multimedia/audio_filehdr.h>
AUDIO_FILE_MAGIC
=
0x2e736e64
AUDIO_FILE_MAGIC
=
0x2e736e64
AUDIO_FILE_ENCODING_MULAW_8
=
1
AUDIO_FILE_ENCODING_MULAW_8
=
1
...
@@ -242,9 +247,9 @@ class Au_read:
...
@@ -242,9 +247,9 @@ class Au_read:
return
'not compressed'
return
'not compressed'
def
getparams
(
self
):
def
getparams
(
self
):
return
self
.
getnchannels
(),
self
.
getsampwidth
(),
\
return
_sunau_params
(
self
.
getnchannels
(),
self
.
getsampwidth
(),
self
.
getframerate
(),
self
.
getnframes
(),
\
self
.
getframerate
(),
self
.
getnframes
(),
self
.
getcomptype
(),
self
.
getcompname
()
self
.
getcomptype
(),
self
.
getcompname
()
)
def
getmarkers
(
self
):
def
getmarkers
(
self
):
return
None
return
None
...
@@ -381,9 +386,9 @@ class Au_write:
...
@@ -381,9 +386,9 @@ class Au_write:
self
.
setcomptype
(
comptype
,
compname
)
self
.
setcomptype
(
comptype
,
compname
)
def
getparams
(
self
):
def
getparams
(
self
):
return
self
.
getnchannels
(),
self
.
getsampwidth
(),
\
return
_sunau_getparams
(
self
.
getnchannels
(),
self
.
getsampwidth
(),
self
.
getframerate
(),
self
.
getnframes
(),
\
self
.
getframerate
(),
self
.
getnframes
(),
self
.
getcomptype
(),
self
.
getcompname
()
self
.
getcomptype
(),
self
.
getcompname
()
)
def
tell
(
self
):
def
tell
(
self
):
return
self
.
_nframeswritten
return
self
.
_nframeswritten
...
...
Lib/test/test_sunau.py
Dosyayı görüntüle @
e06a8965
from
test.support
import
run_unittest
,
TESTFN
from
test.support
import
run_unittest
,
TESTFN
import
unittest
import
unittest
import
pickle
import
os
import
os
import
sunau
import
sunau
...
@@ -62,6 +63,27 @@ class SunAUTest(unittest.TestCase):
...
@@ -62,6 +63,27 @@ class SunAUTest(unittest.TestCase):
self
.
assertEqual
(
self
.
f
.
readframes
(
nframes
),
output
)
self
.
assertEqual
(
self
.
f
.
readframes
(
nframes
),
output
)
self
.
f
.
close
()
self
.
f
.
close
()
def
test_getparams
(
self
):
self
.
f
=
sunau
.
open
(
TESTFN
,
'w'
)
self
.
f
.
setnchannels
(
nchannels
)
self
.
f
.
setsampwidth
(
sampwidth
)
self
.
f
.
setframerate
(
framerate
)
self
.
f
.
setcomptype
(
'ULAW'
,
''
)
output
=
b
'
\0
'
*
nframes
*
nchannels
*
sampwidth
self
.
f
.
writeframes
(
output
)
self
.
f
.
close
()
self
.
f
=
sunau
.
open
(
TESTFN
,
'rb'
)
params
=
self
.
f
.
getparams
()
self
.
assertEqual
(
params
.
nchannels
,
nchannels
)
self
.
assertEqual
(
params
.
sampwidth
,
sampwidth
)
self
.
assertEqual
(
params
.
framerate
,
framerate
)
self
.
assertEqual
(
params
.
nframes
,
nframes
)
self
.
assertEqual
(
params
.
comptype
,
'ULAW'
)
dump
=
pickle
.
dumps
(
params
)
self
.
assertEqual
(
pickle
.
loads
(
dump
),
params
)
def
test_main
():
def
test_main
():
run_unittest
(
SunAUTest
)
run_unittest
(
SunAUTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e06a8965
...
@@ -54,6 +54,9 @@ Core and Builtins
...
@@ -54,6 +54,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #18901: The sunau getparams method now returns a namedtuple rather than
a plain tuple. Patch by Claudiu Popa.
- Issue #17487: The result of the wave getparams method now is pickleable again.
- Issue #17487: The result of the wave getparams method now is pickleable again.
Patch by Claudiu Popa.
Patch by Claudiu Popa.
...
...
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