a5a57d3
From 1aacb4128b7d3ea9cc238b5df2c657b891fe610f Mon Sep 17 00:00:00 2001
a5a57d3
From: Nils Philippsen <nils@redhat.com>
a5a57d3
Date: Thu, 26 Nov 2015 01:01:38 +0100
a5a57d3
Subject: [PATCH 6/6] Python 3: use new raise syntax
a5a57d3
a5a57d3
---
a5a57d3
 python/lib/aubio/midiconv.py | 19 +++++++++++--------
a5a57d3
 1 file changed, 11 insertions(+), 8 deletions(-)
a5a57d3
a5a57d3
diff --git a/python/lib/aubio/midiconv.py b/python/lib/aubio/midiconv.py
a5a57d3
index a859dec..f3e8e32 100644
a5a57d3
--- a/python/lib/aubio/midiconv.py
a5a57d3
+++ b/python/lib/aubio/midiconv.py
a5a57d3
@@ -6,9 +6,11 @@ def note2midi(note):
a5a57d3
     _valid_modifiers = {None: 0, u'♮': 0, '#': +1, u'♯': +1, u'\udd2a': +2, 'b': -1, u'♭': -1, u'\ufffd': -2}
a5a57d3
     _valid_octaves = range(-1, 10)
a5a57d3
     if type(note) not in (str, unicode):
a5a57d3
-        raise TypeError, "a string is required, got %s" % note
a5a57d3
+        raise TypeError("a string is required, got %s" % note)
a5a57d3
     if not (1 < len(note) < 5):
a5a57d3
-        raise ValueError, "string of 2 to 4 characters expected, got %d (%s)" % (len(note), note)
a5a57d3
+        raise ValueError(
a5a57d3
+                "string of 2 to 4 characters expected, got %d (%s)" %
a5a57d3
+                (len(note), note))
a5a57d3
     notename, modifier, octave = [None]*3
a5a57d3
 
a5a57d3
     if len(note) == 4:
a5a57d3
@@ -26,23 +28,24 @@ def note2midi(note):
a5a57d3
     octave = int(octave)
a5a57d3
 
a5a57d3
     if notename not in _valid_notenames:
a5a57d3
-        raise ValueError, "%s is not a valid note name" % notename
a5a57d3
+        raise ValueError("%s is not a valid note name" % notename)
a5a57d3
     if modifier not in _valid_modifiers:
a5a57d3
-        raise ValueError, "%s is not a valid modifier" % modifier
a5a57d3
+        raise ValueError("%s is not a valid modifier" % modifier)
a5a57d3
     if octave not in _valid_octaves:
a5a57d3
-        raise ValueError, "%s is not a valid octave" % octave
a5a57d3
+        raise ValueError("%s is not a valid octave" % octave)
a5a57d3
 
a5a57d3
     midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
a5a57d3
     if midi > 127:
a5a57d3
-        raise ValueError, "%s is outside of the range C-2 to G8" % note
a5a57d3
+        raise ValueError("%s is outside of the range C-2 to G8" % note)
a5a57d3
     return midi
a5a57d3
 
a5a57d3
 def midi2note(midi):
a5a57d3
     " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] "
a5a57d3
     if type(midi) != int:
a5a57d3
-        raise TypeError, "an integer is required, got %s" % midi
a5a57d3
+        raise TypeError("an integer is required, got %s" % midi)
a5a57d3
     if not (-1 < midi < 128):
a5a57d3
-        raise ValueError, "an integer between 0 and 127 is excepted, got %d" % midi
a5a57d3
+        raise ValueError(
a5a57d3
+                "an integer between 0 and 127 is excepted, got %d" % midi)
a5a57d3
     midi = int(midi)
a5a57d3
     _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
a5a57d3
     return _valid_notenames[midi % 12] + str( midi / 12 - 1)
a5a57d3
-- 
a5a57d3
2.5.0
a5a57d3