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
4d35e75c
Kaydet (Commit)
4d35e75c
authored
Tem 25, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17818: aifc.getparams now returns a namedtuple.
Patch by Claudiu Popa.
üst
840c310a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
8 deletions
+55
-8
aifc.rst
Doc/library/aifc.rst
+3
-1
3.4.rst
Doc/whatsnew/3.4.rst
+6
-0
aifc.py
Lib/aifc.py
+11
-6
test_aifc.py
Lib/test/test_aifc.py
+32
-0
test_pyclbr.py
Lib/test/test_pyclbr.py
+1
-1
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/aifc.rst
Dosyayı görüntüle @
4d35e75c
...
...
@@ -96,7 +96,9 @@ following methods:
.. method:: aifc.getparams()
Return a tuple consisting of all of the above values in the above order.
Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,
framerate, nframes, comptype, compname)``, equivalent to output of the
:meth:`get\*` methods.
.. method:: aifc.getmarkers()
...
...
Doc/whatsnew/3.4.rst
Dosyayı görüntüle @
4d35e75c
...
...
@@ -173,6 +173,12 @@ be specified on the command line, and ``-f`` is a shorthand for ``-o
FAIL_FAST`` (to parallel the similar option supported by the :mod:`unittest`
CLI). (Contributed by R. David Murray in :issue:`11390`.)
aifc
----
The :meth:`~aifc.getparams` method now returns a namedtuple rather than a
plain tuple. (Contributed by Claudiu Popa in :issue:`17818`.)
functools
---------
...
...
Lib/aifc.py
Dosyayı görüntüle @
4d35e75c
...
...
@@ -69,7 +69,7 @@ This returns an instance of a class with the following public methods:
getcomptype() -- returns compression type ('NONE' for AIFF files)
getcompname() -- returns human-readable version of
compression type ('not compressed' for AIFF files)
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() -- get the list of marks in the audio file or None
if there are no marks
...
...
@@ -252,6 +252,11 @@ def _write_float(f, x):
_write_ulong
(
f
,
lomant
)
from
chunk
import
Chunk
from
collections
import
namedtuple
_aifc_params
=
namedtuple
(
'_aifc_params'
,
'nchannels sampwidth framerate nframes comptype compname'
)
class
Aifc_read
:
# Variables used in this class:
...
...
@@ -378,9 +383,9 @@ class Aifc_read:
## return self._version
def
getparams
(
self
):
return
self
.
getnchannels
(),
self
.
getsampwidth
(),
\
self
.
getframerate
(),
self
.
getnframes
(),
\
self
.
getcomptype
(),
self
.
getcompname
(
)
return
_aifc_params
(
self
.
getnchannels
(),
self
.
getsampwidth
(),
self
.
getframerate
(),
self
.
getnframes
(),
self
.
getcomptype
(),
self
.
getcompname
()
)
def
getmarkers
(
self
):
if
len
(
self
.
_markers
)
==
0
:
...
...
@@ -658,8 +663,8 @@ class Aifc_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
_aifc_params
(
self
.
_nchannels
,
self
.
_sampwidth
,
self
.
_framerate
,
self
.
_nframes
,
self
.
_comptype
,
self
.
_compname
)
def
setmark
(
self
,
id
,
pos
,
name
):
if
id
<=
0
:
...
...
Lib/test/test_aifc.py
Dosyayı görüntüle @
4d35e75c
...
...
@@ -3,6 +3,7 @@ import unittest
import
os
import
io
import
struct
import
pickle
import
aifc
...
...
@@ -31,6 +32,7 @@ class AIFCTest(unittest.TestCase):
def
test_params
(
self
):
f
=
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
params
=
f
.
getparams
()
self
.
assertEqual
(
f
.
getfp
()
.
name
,
self
.
sndfilepath
)
self
.
assertEqual
(
f
.
getnchannels
(),
2
)
self
.
assertEqual
(
f
.
getsampwidth
(),
2
)
...
...
@@ -43,6 +45,36 @@ class AIFCTest(unittest.TestCase):
(
2
,
2
,
48000
,
14400
,
b
'NONE'
,
b
'not compressed'
),
)
params
=
f
.
getparams
()
self
.
assertEqual
(
params
.
nchannels
,
2
)
self
.
assertEqual
(
params
.
sampwidth
,
2
)
self
.
assertEqual
(
params
.
framerate
,
48000
)
self
.
assertEqual
(
params
.
nframes
,
14400
)
self
.
assertEqual
(
params
.
comptype
,
b
'NONE'
)
self
.
assertEqual
(
params
.
compname
,
b
'not compressed'
)
def
test_params_added
(
self
):
f
=
self
.
f
=
aifc
.
open
(
TESTFN
,
'wb'
)
f
.
aiff
()
f
.
setparams
((
1
,
1
,
1
,
1
,
b
'NONE'
,
b
''
))
f
.
close
()
f
=
self
.
f
=
aifc
.
open
(
TESTFN
,
'rb'
)
params
=
f
.
getparams
()
self
.
assertEqual
(
params
.
nchannels
,
f
.
getnchannels
())
self
.
assertEqual
(
params
.
sampwidth
,
f
.
getsampwidth
())
self
.
assertEqual
(
params
.
framerate
,
f
.
getframerate
())
self
.
assertEqual
(
params
.
nframes
,
f
.
getnframes
())
self
.
assertEqual
(
params
.
comptype
,
f
.
getcomptype
())
self
.
assertEqual
(
params
.
compname
,
f
.
getcompname
())
def
test_getparams_picklable
(
self
):
self
.
f
=
aifc
.
open
(
self
.
sndfilepath
)
params
=
self
.
f
.
getparams
()
dump
=
pickle
.
dumps
(
params
)
self
.
assertEqual
(
pickle
.
loads
(
dump
),
params
)
self
.
f
.
close
()
def
test_context_manager
(
self
):
with
open
(
self
.
sndfilepath
,
'rb'
)
as
testfile
:
with
aifc
.
open
(
testfile
)
as
f
:
...
...
Lib/test/test_pyclbr.py
Dosyayı görüntüle @
4d35e75c
...
...
@@ -158,7 +158,7 @@ class PyclbrTest(TestCase):
cm
(
'random'
,
ignore
=
(
'Random'
,))
# from _random import Random as CoreGenerator
cm
(
'cgi'
,
ignore
=
(
'log'
,))
# set with = in module
cm
(
'pickle'
)
cm
(
'aifc'
,
ignore
=
(
'openfp'
,))
# set with = in module
cm
(
'aifc'
,
ignore
=
(
'openfp'
,
'_aifc_params'
))
# set with = in module
cm
(
'sre_parse'
,
ignore
=
(
'dump'
,))
# from sre_constants import *
cm
(
'pdb'
)
cm
(
'pydoc'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
4d35e75c
...
...
@@ -166,6 +166,8 @@ Core and Builtins
Library
-------
-
Issue
#
17818
:
aifc
.
getparams
now
returns
a
namedtuple
.
-
Issue
#
18549
:
Eliminate
dead
code
in
socket_ntohl
()
-
Issue
#
18530
:
Remove
additional
stat
call
from
posixpath
.
ismount
.
...
...
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