Changeset b8ed85e for python/lib/aubio


Ignore:
Timestamp:
Nov 26, 2015, 2:48:10 PM (9 years ago)
Author:
Nils Philippsen <nils@tiptoe.de>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
4041a6d
Parents:
ac7e49b
git-author:
Nils Philippsen <nils@tiptoe.de> (11/26/15 01:01:38)
git-committer:
Nils Philippsen <nils@tiptoe.de> (11/26/15 14:48:10)
Message:

Python 3: use new raise syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/midiconv.py

    rac7e49b rb8ed85e  
    77    _valid_octaves = range(-1, 10)
    88    if type(note) not in (str, unicode):
    9         raise TypeError, "a string is required, got %s" % note
     9        raise TypeError("a string is required, got %s" % note)
    1010    if not (1 < len(note) < 5):
    11         raise ValueError, "string of 2 to 4 characters expected, got %d (%s)" % (len(note), note)
     11        raise ValueError(
     12                "string of 2 to 4 characters expected, got %d (%s)" %
     13                (len(note), note))
    1214    notename, modifier, octave = [None]*3
    1315
     
    2729
    2830    if notename not in _valid_notenames:
    29         raise ValueError, "%s is not a valid note name" % notename
     31        raise ValueError("%s is not a valid note name" % notename)
    3032    if modifier not in _valid_modifiers:
    31         raise ValueError, "%s is not a valid modifier" % modifier
     33        raise ValueError("%s is not a valid modifier" % modifier)
    3234    if octave not in _valid_octaves:
    33         raise ValueError, "%s is not a valid octave" % octave
     35        raise ValueError("%s is not a valid octave" % octave)
    3436
    3537    midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
    3638    if midi > 127:
    37         raise ValueError, "%s is outside of the range C-2 to G8" % note
     39        raise ValueError("%s is outside of the range C-2 to G8" % note)
    3840    return midi
    3941
     
    4143    " convert midi note number to note name, e.g. [0, 127] -> [C-1, G9] "
    4244    if type(midi) != int:
    43         raise TypeError, "an integer is required, got %s" % midi
     45        raise TypeError("an integer is required, got %s" % midi)
    4446    if not (-1 < midi < 128):
    45         raise ValueError, "an integer between 0 and 127 is excepted, got %d" % midi
     47        raise ValueError(
     48                "an integer between 0 and 127 is excepted, got %d" % midi)
    4649    midi = int(midi)
    4750    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
Note: See TracChangeset for help on using the changeset viewer.