History

[py] wrap long lines in midiconv.py

Paul Brossier committed 8 years ago

Commit 40136171 parent cc3f1291 file · +10 −6Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/lib/aubio/midiconv.py+10−6
@@ -24,10 +24,11 @@ def note2midi(note): · 23 unmodified lines
2424 }
2525 _valid_octaves = range(-1, 10)
2626 if not isinstance(note, str_instances):
27− raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))
27+ msg = "a string is required, got {:s} ({:s})"
28+ raise TypeError(msg.format(str(type(note)), repr(note)))
2829 if len(note) not in range(2, 5):
29− raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \
30− % (len(note), note))
30+ msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
31+ raise ValueError(msg.format(len(note), note))
3132 notename, modifier, octave = [None]*3
3233
3334 if len(note) == 4:
@@ -51,7 +52,8 @@ def note2midi(note): · 17 unmodified lines
5152 if octave not in _valid_octaves:
5253 raise ValueError("%s is not a valid octave" % octave)
5354
54− midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
55+ midi = 12 + octave * 12 + _valid_notenames[notename] \
56+ + _valid_modifiers[modifier]
5557 if midi > 127:
5658 raise ValueError("%s is outside of the range C-2 to G8" % note)
5759 return midi
@@ -61,8 +63,10 @@ def midi2note(midi): · 3 unmodified lines
6163 if not isinstance(midi, int_instances):
6264 raise TypeError("an integer is required, got %s" % midi)
6365 if midi not in range(0, 128):
64− raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)
65− _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
66+ msg = "an integer between 0 and 127 is excepted, got {:d}"
67+ raise ValueError(msg.format(midi))
68+ _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
69+ 'A', 'A#', 'B']
6670 return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
6771
6872 def freq2note(freq):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t