Skip to content

Commit 104d912

Browse files
committed
Replace double quotes with single quotes in most literals
1 parent 64d7907 commit 104d912

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

sounddevice.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def playrec(data, samplerate=None, channels=None, dtype=None,
429429
input_frames = ctx.check_out(out, output_frames, channels, dtype,
430430
input_mapping)
431431
if input_frames != output_frames:
432-
raise PortAudioError("len(data) != len(out)")
432+
raise PortAudioError('len(data) != len(out)')
433433
ctx.frames = input_frames
434434

435435
def callback(indata, outdata, frames, time, status):
@@ -497,7 +497,7 @@ def get_status():
497497
if _last_callback:
498498
return _last_callback.status
499499
else:
500-
raise RuntimeError("play()/rec()/playrec() was not called yet")
500+
raise RuntimeError('play()/rec()/playrec() was not called yet')
501501

502502

503503
def query_devices(device=None, kind=None):
@@ -607,14 +607,14 @@ def query_devices(device=None, kind=None):
607607
608608
"""
609609
if kind not in ('input', 'output', None):
610-
raise ValueError("Invalid kind: {0!r}".format(kind))
610+
raise ValueError('Invalid kind: {0!r}'.format(kind))
611611
if device is None and kind is None:
612612
return DeviceList(query_devices(i)
613613
for i in range(_check(_lib.Pa_GetDeviceCount())))
614614
device = _get_device_id(device, kind, raise_on_error=True)
615615
info = _lib.Pa_GetDeviceInfo(device)
616616
if not info:
617-
raise PortAudioError("Error querying device {0}".format(device))
617+
raise PortAudioError('Error querying device {0}'.format(device))
618618
assert info.structVersion == 2
619619
device_dict = {
620620
'name': _ffi.string(info.name).decode('mbcs' if info.hostApi in (
@@ -631,7 +631,7 @@ def query_devices(device=None, kind=None):
631631
}
632632
if kind and device_dict['max_' + kind + '_channels'] < 1:
633633
raise ValueError(
634-
"Not an {0} device: {1!r}".format(kind, device_dict['name']))
634+
'Not an {0} device: {1!r}'.format(kind, device_dict['name']))
635635
return device_dict
636636

637637

@@ -677,7 +677,7 @@ def query_hostapis(index=None):
677677
for i in range(_check(_lib.Pa_GetHostApiCount())))
678678
info = _lib.Pa_GetHostApiInfo(index)
679679
if not info:
680-
raise PortAudioError("Error querying host API {0}".format(index))
680+
raise PortAudioError('Error querying host API {0}'.format(index))
681681
assert info.structVersion == 1
682682
return {
683683
'name': _ffi.string(info.name).decode(),
@@ -794,7 +794,7 @@ def __init__(self, kind, samplerate, blocksize, device, channels, dtype,
794794
self._samplesize = isize, osize
795795
if isamplerate != osamplerate:
796796
raise PortAudioError(
797-
"Input and output device must have the same samplerate")
797+
'Input and output device must have the same samplerate')
798798
else:
799799
samplerate = isamplerate
800800
else:
@@ -813,23 +813,23 @@ def __init__(self, kind, samplerate, blocksize, device, channels, dtype,
813813

814814
if callback_wrapper:
815815
self._callback = _ffi.callback(
816-
"PaStreamCallback", callback_wrapper, error=_lib.paAbort)
816+
'PaStreamCallback', callback_wrapper, error=_lib.paAbort)
817817
else:
818818
self._callback = _ffi.NULL
819819

820-
self._ptr = _ffi.new("PaStream**")
820+
self._ptr = _ffi.new('PaStream**')
821821
_check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
822822
samplerate, blocksize, stream_flags,
823823
self._callback, _ffi.NULL),
824-
"Error opening {0}".format(self.__class__.__name__))
824+
'Error opening {0}'.format(self.__class__.__name__))
825825

826826
# dereference PaStream** --> PaStream*
827827
self._ptr = self._ptr[0]
828828

829829
self._blocksize = blocksize
830830
info = _lib.Pa_GetStreamInfo(self._ptr)
831831
if not info:
832-
raise PortAudioError("Could not obtain stream info")
832+
raise PortAudioError('Could not obtain stream info')
833833
# TODO: assert info.structVersion == 1
834834
self._samplerate = info.sampleRate
835835
if not oparameters:
@@ -845,7 +845,7 @@ def finished_callback_wrapper(_):
845845
return finished_callback()
846846

847847
self._finished_callback = _ffi.callback(
848-
"PaStreamFinishedCallback", finished_callback_wrapper)
848+
'PaStreamFinishedCallback', finished_callback_wrapper)
849849
_check(_lib.Pa_SetStreamFinishedCallback(self._ptr,
850850
self._finished_callback))
851851

@@ -974,7 +974,7 @@ def time(self):
974974
"""
975975
time = _lib.Pa_GetStreamTime(self._ptr)
976976
if not time:
977-
raise PortAudioError("Error getting stream time")
977+
raise PortAudioError('Error getting stream time')
978978
return time
979979

980980
@property
@@ -1024,7 +1024,7 @@ def start(self):
10241024
"""
10251025
err = _lib.Pa_StartStream(self._ptr)
10261026
if err != _lib.paStreamIsNotStopped:
1027-
_check(err, "Error starting stream")
1027+
_check(err, 'Error starting stream')
10281028

10291029
def stop(self):
10301030
"""Terminate audio processing.
@@ -1039,7 +1039,7 @@ def stop(self):
10391039
"""
10401040
err = _lib.Pa_StopStream(self._ptr)
10411041
if err != _lib.paStreamIsStopped:
1042-
_check(err, "Error stopping stream")
1042+
_check(err, 'Error stopping stream')
10431043

10441044
def abort(self):
10451045
"""Terminate audio processing immediately.
@@ -1053,7 +1053,7 @@ def abort(self):
10531053
"""
10541054
err = _lib.Pa_AbortStream(self._ptr)
10551055
if err != _lib.paStreamIsStopped:
1056-
_check(err, "Error aborting stream")
1056+
_check(err, 'Error aborting stream')
10571057

10581058
def close(self, ignore_errors=True):
10591059
"""Close the stream.
@@ -1064,7 +1064,7 @@ def close(self, ignore_errors=True):
10641064
"""
10651065
err = _lib.Pa_CloseStream(self._ptr)
10661066
if not ignore_errors:
1067-
_check(err, "Error closing stream")
1067+
_check(err, 'Error closing stream')
10681068

10691069

10701070
class RawInputStream(_StreamBase):
@@ -1149,7 +1149,7 @@ def read(self, frames):
11491149
"""
11501150
channels, _ = _split(self._channels)
11511151
samplesize, _ = _split(self._samplesize)
1152-
data = _ffi.new("signed char[]", channels * samplesize * frames)
1152+
data = _ffi.new('signed char[]', channels * samplesize * frames)
11531153
err = _lib.Pa_ReadStream(self._ptr, data, frames)
11541154
if err == _lib.paInputOverflowed:
11551155
overflowed = True
@@ -1249,10 +1249,10 @@ def write(self, data):
12491249
_, channels = _split(self._channels)
12501250
samples, remainder = divmod(len(data), samplesize)
12511251
if remainder:
1252-
raise ValueError("len(data) not divisible by samplesize")
1252+
raise ValueError('len(data) not divisible by samplesize')
12531253
frames, remainder = divmod(samples, channels)
12541254
if remainder:
1255-
raise ValueError("Number of samples not divisible by channels")
1255+
raise ValueError('Number of samples not divisible by channels')
12561256
err = _lib.Pa_WriteStream(self._ptr, data, frames)
12571257
if err == _lib.paOutputUnderflowed:
12581258
underflowed = True
@@ -1489,12 +1489,12 @@ def write(self, data):
14891489
_, dtype = _split(self._dtype)
14901490
_, channels = _split(self._channels)
14911491
if data.ndim > 1 and data.shape[1] != channels:
1492-
raise ValueError("Number of channels must match")
1492+
raise ValueError('Number of channels must match')
14931493
if data.dtype != dtype:
1494-
raise TypeError("dtype mismatch: {0!r} vs {1!r}".format(
1494+
raise TypeError('dtype mismatch: {0!r} vs {1!r}'.format(
14951495
data.dtype.name, dtype))
14961496
if not data.flags.c_contiguous:
1497-
raise TypeError("data must be C-contiguous")
1497+
raise TypeError('data must be C-contiguous')
14981498
return RawOutputStream.write(self, data)
14991499

15001500

@@ -1778,8 +1778,8 @@ def __repr__(self):
17781778
digits = len(str(_lib.Pa_GetDeviceCount() - 1))
17791779
hostapi_names = [hostapi['name'] for hostapi in query_hostapis()]
17801780
text = '\n'.join(
1781-
u"{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)".format(
1782-
mark=(" ", ">", "<", "*")[(idx == idev) + 2 * (idx == odev)],
1781+
u'{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)'.format(
1782+
mark=(' ', '>', '<', '*')[(idx == idev) + 2 * (idx == odev)],
17831783
idx=idx,
17841784
dig=digits,
17851785
name=info['name'],
@@ -1822,11 +1822,11 @@ def __init__(self, flags=0x0):
18221822
def __repr__(self):
18231823
flags = str(self)
18241824
if not flags:
1825-
flags = "no flags set"
1826-
return "<sounddevice.CallbackFlags: {0}>".format(flags)
1825+
flags = 'no flags set'
1826+
return '<sounddevice.CallbackFlags: {0}>'.format(flags)
18271827

18281828
def __str__(self):
1829-
return ", ".join(name.replace('_', ' ') for name in dir(self)
1829+
return ', '.join(name.replace('_', ' ') for name in dir(self)
18301830
if not name.startswith('_') and getattr(self, name))
18311831

18321832
def __bool__(self):
@@ -1923,7 +1923,7 @@ def __setitem__(self, index, value):
19231923
self._pair[index] = value
19241924

19251925
def __repr__(self):
1926-
return "[{0[0]!r}, {0[1]!r}]".format(self)
1926+
return '[{0[0]!r}, {0[1]!r}]'.format(self)
19271927

19281928

19291929
class default(object):
@@ -2155,7 +2155,7 @@ def __init__(self, loop=False):
21552155
assert numpy # avoid "imported but unused" message (W0611)
21562156
except ImportError:
21572157
raise ImportError(
2158-
"NumPy must be installed for play()/rec()/playrec()")
2158+
'NumPy must be installed for play()/rec()/playrec()')
21592159
self.loop = loop
21602160
self.event = threading.Event()
21612161
self.status = CallbackFlags()
@@ -2174,7 +2174,7 @@ def check_data(self, data, mapping, device):
21742174
pass # No problem, mono data is duplicated into arbitrary channels
21752175
elif data.shape[1] != len(mapping):
21762176
raise ValueError(
2177-
"number of output channels != size of output mapping")
2177+
'number of output channels != size of output mapping')
21782178
# Apparently, some PortAudio host APIs duplicate mono streams to the
21792179
# first two channels, which is unexpected when specifying mapping=[1].
21802180
# In this case, we play silence on the second channel, but only if the
@@ -2184,7 +2184,7 @@ def check_data(self, data, mapping, device):
21842184
channels = 2
21852185
silent_channels = np.setdiff1d(np.arange(channels), mapping)
21862186
if len(mapping) + len(silent_channels) != channels:
2187-
raise ValueError("each channel may only appear once in mapping")
2187+
raise ValueError('each channel may only appear once in mapping')
21882188

21892189
self.data = data
21902190
self.output_channels = channels
@@ -2198,13 +2198,13 @@ def check_out(self, out, frames, channels, dtype, mapping):
21982198
import numpy as np
21992199
if out is None:
22002200
if frames is None:
2201-
raise TypeError("frames must be specified")
2201+
raise TypeError('frames must be specified')
22022202
if channels is None:
22032203
channels = default.channels['input']
22042204
if channels is None:
22052205
if mapping is None:
22062206
raise TypeError(
2207-
"Unable to determine number of input channels")
2207+
'Unable to determine number of input channels')
22082208
else:
22092209
channels = len(np.atleast_1d(mapping))
22102210
if dtype is None:
@@ -2217,7 +2217,7 @@ def check_out(self, out, frames, channels, dtype, mapping):
22172217
mapping, channels = _check_mapping(mapping, channels)
22182218
if out.shape[1] != len(mapping):
22192219
raise ValueError(
2220-
"number of input channels != size of input mapping")
2220+
'number of input channels != size of input mapping')
22212221

22222222
self.out = out
22232223
self.input_channels = channels
@@ -2298,7 +2298,7 @@ def _check_mapping(mapping, channels):
22982298
else:
22992299
mapping = np.atleast_1d(mapping)
23002300
if mapping.min() < 1:
2301-
raise ValueError("channel numbers must not be < 1")
2301+
raise ValueError('channel numbers must not be < 1')
23022302
channels = mapping.max()
23032303
mapping -= 1 # channel numbers start with 1
23042304
return mapping, channels
@@ -2313,7 +2313,7 @@ def _check_dtype(dtype):
23132313
elif dtype == 'float64':
23142314
dtype = 'float32'
23152315
else:
2316-
raise TypeError("Unsupported data type: " + repr(dtype))
2316+
raise TypeError('Unsupported data type: ' + repr(dtype))
23172317
return dtype
23182318

23192319

@@ -2342,14 +2342,14 @@ def _get_stream_parameters(kind, device, channels, dtype, latency, samplerate):
23422342
try:
23432343
sampleformat = _sampleformats[dtype]
23442344
except KeyError:
2345-
raise ValueError("Invalid " + kind + " sample format")
2345+
raise ValueError('Invalid ' + kind + ' sample format')
23462346
samplesize = _check(_lib.Pa_GetSampleSize(sampleformat))
23472347
if latency in ('low', 'high'):
23482348
latency = info['default_' + latency + '_' + kind + '_latency']
23492349
if samplerate is None:
23502350
samplerate = info['default_samplerate']
23512351
parameters = _ffi.new(
2352-
"PaStreamParameters*",
2352+
'PaStreamParameters*',
23532353
(device, channels, sampleformat, latency, _ffi.NULL))
23542354
return parameters, dtype, samplesize, samplerate
23552355

@@ -2389,18 +2389,18 @@ def _split(value):
23892389
except TypeError:
23902390
invalue = outvalue = value
23912391
except ValueError:
2392-
raise ValueError("Only single values and pairs are allowed")
2392+
raise ValueError('Only single values and pairs are allowed')
23932393
return invalue, outvalue
23942394

23952395

23962396
def _check(err, msg=""):
23972397
"""Raise error for non-zero error codes."""
23982398
if err < 0:
2399-
msg += ": " if msg else ""
2399+
msg += ': ' if msg else ''
24002400
if err == _lib.paUnanticipatedHostError:
24012401
info = _lib.Pa_GetLastHostErrorInfo()
24022402
hostapi = _lib.Pa_HostApiTypeIdToHostApiIndex(info.hostApiType)
2403-
msg += "Unanticipated host API {0} error {1}: {2!r}".format(
2403+
msg += 'Unanticipated host API {0} error {1}: {2!r}'.format(
24042404
hostapi, info.errorCode, _ffi.string(info.errorText).decode())
24052405
else:
24062406
msg += _ffi.string(_lib.Pa_GetErrorText(err)).decode()
@@ -2424,7 +2424,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
24242424
if idev == odev:
24252425
id_or_query_string = idev
24262426
else:
2427-
raise ValueError("Input and output device are different: {0!r}"
2427+
raise ValueError('Input and output device are different: {0!r}'
24282428
.format(id_or_query_string))
24292429

24302430
if isinstance(id_or_query_string, int):
@@ -2458,15 +2458,15 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
24582458
if not matches:
24592459
if raise_on_error:
24602460
raise ValueError(
2461-
"No " + kind + " device matching " + repr(id_or_query_string))
2461+
'No ' + kind + ' device matching ' + repr(id_or_query_string))
24622462
else:
24632463
return -1
24642464
if len(matches) > 1:
24652465
if len(exact_device_matches) == 1:
24662466
return exact_device_matches[0]
24672467
if raise_on_error:
2468-
raise ValueError("Multiple " + kind + " devices found for " +
2469-
repr(id_or_query_string) + ":\n" +
2468+
raise ValueError('Multiple ' + kind + ' devices found for ' +
2469+
repr(id_or_query_string) + ':\n' +
24702470
'\n'.join('[{0}] {1}'.format(id, name)
24712471
for id, name in matches))
24722472
else:
@@ -2476,14 +2476,14 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
24762476

24772477
def _initialize():
24782478
"""Initialize PortAudio."""
2479-
_check(_lib.Pa_Initialize(), "Error initializing PortAudio")
2479+
_check(_lib.Pa_Initialize(), 'Error initializing PortAudio')
24802480
_atexit.register(_lib.Pa_Terminate)
24812481

24822482

24832483
def _terminate():
24842484
"""Terminate PortAudio."""
24852485
_atexit.unregister(_lib.Pa_Terminate)
2486-
_check(_lib.Pa_Terminate(), "Error terminating PortAudio")
2486+
_check(_lib.Pa_Terminate(), 'Error terminating PortAudio')
24872487

24882488

24892489
def _ignore_stderr():

0 commit comments

Comments
 (0)