From 40136171dbc5df8e7809fa24cb8f43dfc52df38d Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 29 Oct 2018 23:54:28 +0100 Subject: [PATCH] [py] wrap long lines in midiconv.py --- python/lib/aubio/midiconv.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/lib/aubio/midiconv.py b/python/lib/aubio/midiconv.py index c79523f5..d3dc5540 100644 --- a/python/lib/aubio/midiconv.py +++ b/python/lib/aubio/midiconv.py @@ -24,10 +24,11 @@ def note2midi(note): } _valid_octaves = range(-1, 10) if not isinstance(note, str_instances): - raise TypeError("a string is required, got %s (%s)" % (note, str(type(note)))) + msg = "a string is required, got {:s} ({:s})" + raise TypeError(msg.format(str(type(note)), repr(note))) if len(note) not in range(2, 5): - raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \ - % (len(note), note)) + msg = "string of 2 to 4 characters expected, got {:d} ({:s})" + raise ValueError(msg.format(len(note), note)) notename, modifier, octave = [None]*3 if len(note) == 4: @@ -51,7 +52,8 @@ def note2midi(note): if octave not in _valid_octaves: raise ValueError("%s is not a valid octave" % octave) - midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier] + midi = 12 + octave * 12 + _valid_notenames[notename] \ + + _valid_modifiers[modifier] if midi > 127: raise ValueError("%s is outside of the range C-2 to G8" % note) return midi @@ -61,8 +63,10 @@ def midi2note(midi): if not isinstance(midi, int_instances): raise TypeError("an integer is required, got %s" % midi) if midi not in range(0, 128): - raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi) - _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] + msg = "an integer between 0 and 127 is excepted, got {:d}" + raise ValueError(msg.format(midi)) + _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', + 'A', 'A#', 'B'] return _valid_notenames[midi % 12] + str(int(midi / 12) - 1) def freq2note(freq): -- 2.11.0