Skip to content

Commit 7887623

Browse files
committed
rename nframes() and get_nframes()
I never really liked these names.
1 parent 9d3554b commit 7887623

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

arver/audio/_audio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static PyObject *checksums(PyObject *self, PyObject *args)
174174
return Py_BuildValue("III", ar.v1, ar.v2, crc);
175175
}
176176

177-
static PyObject *nframes(PyObject *self, PyObject *args)
177+
static PyObject *frame_count(PyObject *self, PyObject *args)
178178
{
179179
const char *path = NULL;
180180
SNDFILE *file = NULL;
@@ -205,7 +205,7 @@ static PyObject *libsndfile_version(PyObject *self, PyObject *args)
205205

206206
static PyMethodDef methods[] = {
207207
{ "checksums", checksums, METH_VARARGS, PyDoc_STR("Calculate AccurateRip and CRC32 checksums of an audio file.") },
208-
{ "nframes", nframes, METH_VARARGS, PyDoc_STR("Get the number of audio frames in a file.") },
208+
{ "frame_count", frame_count, METH_VARARGS, PyDoc_STR("Get the number of audio frames in a file.") },
209209
{ "libsndfile_version", libsndfile_version, METH_NOARGS, PyDoc_STR("Get libsndfile version string.") },
210210
{ NULL, NULL, 0, NULL },
211211
};

arver/audio/properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from arver.audio import _audio # type: ignore
99

1010

11-
def get_nframes(path: str) -> int:
11+
def get_frame_count(path: str) -> int:
1212
"""
1313
Return the number of frames in a supported audio file. A frame
1414
is a set of samples, one sample per channel.
@@ -18,7 +18,7 @@ def get_nframes(path: str) -> int:
1818
will raise TypeError for any other audio format, or OSError when
1919
libsndfile can't load audio samples from the file for any reason.
2020
"""
21-
return _audio.nframes(path)
21+
return _audio.frame_count(path)
2222

2323

2424
def get_libsndfile_version() -> str:

arver/rip/rip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import ClassVar, List, Optional
88

99
from arver.audio.checksums import get_checksums
10-
from arver.audio.properties import get_nframes
10+
from arver.audio.properties import get_frame_count
1111
from arver.disc.info import DiscInfo, DiscType
1212
from arver.disc.utils import frames_to_msf
1313

@@ -37,7 +37,7 @@ def __init__(self, path: str) -> None:
3737
self.path: str = path
3838

3939
try:
40-
self._audio_frames = get_nframes(path)
40+
self._audio_frames = get_frame_count(path)
4141
self.cdda_frames = self._audio_frames // AUDIO_FRAMES_PER_CD_SECTOR
4242
except (OSError, TypeError) as exc:
4343
raise AudioFormatError from exc

tests/_audio_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def test_corrupted_audio(self):
4747
_audio.checksums(CORRUPTED_AUDIO_PATH, 1, 9)
4848

4949

50-
class TestExceptionsNframes(unittest.TestCase):
50+
class TestExceptionsFrameCount(unittest.TestCase):
5151
"""Test exceptions raised when getting the number of audio frames in a file."""
5252

5353
def test_nonexistent_file(self):
5454
with self.assertRaisesRegex(OSError, 'No such file or directory'):
55-
_audio.nframes('does_not_exist.flac')
55+
_audio.frame_count('does_not_exist.flac')
5656

5757
def test_not_audio(self):
5858
with self.assertRaisesRegex(OSError, '(unknown format|Format not recognised)'):
59-
_audio.nframes(NOT_AUDIO_PATH)
59+
_audio.frame_count(NOT_AUDIO_PATH)
6060

6161
def test_unsupported_audio_format(self):
6262
with self.assertRaisesRegex(TypeError, 'Unsupported audio format'):
63-
_audio.nframes(SAMPLE_VORBIS_PATH)
63+
_audio.frame_count(SAMPLE_VORBIS_PATH)

tests/properties_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import unittest
77

8-
from arver.audio.properties import get_nframes
8+
from arver.audio.properties import get_frame_count
99

1010
CWD = os.path.abspath(os.path.dirname(__file__))
1111
SAMPLE_WAV_PATH = CWD + '/data/samples/sample.wav'
@@ -18,9 +18,9 @@ class TestGetNFrames(unittest.TestCase):
1818
expected_frames = 44100 # one second of CDDA audio: number of frames same as sampling rate
1919

2020
def test_wav(self):
21-
frames = get_nframes(SAMPLE_WAV_PATH)
21+
frames = get_frame_count(SAMPLE_WAV_PATH)
2222
self.assertEqual(frames, self.expected_frames)
2323

2424
def test_flac(self):
25-
frames = get_nframes(SAMPLE_FLAC_PATH)
25+
frames = get_frame_count(SAMPLE_FLAC_PATH)
2626
self.assertEqual(frames, self.expected_frames)

0 commit comments

Comments
 (0)