diff --git a/beets/library.py b/beets/library.py index ed1938671..99397013b 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1325,7 +1325,7 @@ class DefaultTemplateFunctions(object): additional context to the functions -- specifically, the Item being evaluated. """ - _prefix = b'tmpl_' + _prefix = 'tmpl_' def __init__(self, item=None, lib=None): """Parametrize the functions. If `item` or `lib` is None, then diff --git a/beets/plugins.py b/beets/plugins.py index ebc37796c..239f64fbb 100755 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -28,7 +28,7 @@ import beets from beets import logging from beets import mediafile -PLUGIN_NAMESPACE = b'beetsplug' +PLUGIN_NAMESPACE = 'beetsplug' # Plugins using the Last.fm API can share the same API key. LASTFM_KEY = '2dc3914abf35f0d9c92d97d8f8e42b43' @@ -72,7 +72,7 @@ class BeetsPlugin(object): def __init__(self, name=None): """Perform one-time plugin setup. """ - self.name = name or self.__module__.decode('utf8').split('.')[-1] + self.name = name or self.__module__.split('.')[-1] self.config = beets.config[self.name] if not self.template_funcs: self.template_funcs = {} @@ -247,8 +247,7 @@ def load_plugins(names=()): BeetsPlugin subclasses desired. """ for name in names: - bname = name.encode('utf8') - modname = b'%s.%s' % (PLUGIN_NAMESPACE, bname) + modname = '{0}.{1}'.format(PLUGIN_NAMESPACE, name) try: try: namespace = __import__(modname, None, None) @@ -259,7 +258,7 @@ def load_plugins(names=()): else: raise else: - for obj in getattr(namespace, bname).__dict__.values(): + for obj in getattr(namespace, name).__dict__.values(): if isinstance(obj, type) and issubclass(obj, BeetsPlugin) \ and obj != BeetsPlugin and obj not in _classes: _classes.add(obj) @@ -313,7 +312,7 @@ def queries(): def types(model_cls): # Gives us `item_types` and `album_types` - attr_name = b'{0}_types'.format(model_cls.__name__.lower()) + attr_name = '{0}_types'.format(model_cls.__name__.lower()) types = {} for plugin in find_plugins(): plugin_types = getattr(plugin, attr_name, {}) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index e82f48434..797df44d3 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -1132,7 +1132,7 @@ def _configure(options): # Add any additional config files specified with --config. This # special handling lets specified plugins get loaded before we # finish parsing the command line. - if getattr(options, b'config', None) is not None: + if getattr(options, 'config', None) is not None: config_path = options.config del options.config config.set_file(config_path) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 2e4c4de15..3cc270aee 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -713,7 +713,7 @@ def max_filename_length(path, limit=MAX_FILENAME_LENGTH): misreports its capacity). If it cannot be determined (e.g., on Windows), return `limit`. """ - if hasattr(os, b'statvfs'): + if hasattr(os, 'statvfs'): try: res = os.statvfs(path) except OSError: diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py index d20ef3071..05f0892c2 100644 --- a/beets/util/functemplate.py +++ b/beets/util/functemplate.py @@ -43,8 +43,8 @@ GROUP_CLOSE = u'}' ARG_SEP = u',' ESCAPE_CHAR = u'$' -VARIABLE_PREFIX = b'__var_' -FUNCTION_PREFIX = b'__func_' +VARIABLE_PREFIX = '__var_' +FUNCTION_PREFIX = '__func_' class Environment(object): @@ -73,7 +73,7 @@ def ex_literal(val): value. """ if val is None: - return ast.Name(b'None', ast.Load()) + return ast.Name('None', ast.Load()) elif isinstance(val, NUMERIC_TYPES): return ast.Num(val) elif isinstance(val, bool): @@ -126,7 +126,7 @@ def compile_func(arg_names, statements, name='_the_func', debug=False): mod = ast.Module([func_def]) ast.fix_missing_locations(mod) - prog = compile(mod, b'', b'exec') + prog = compile(mod, '', 'exec') # Debug: show bytecode. if debug: @@ -209,11 +209,11 @@ class Call(object): # Create a subexpression that joins the result components of # the arguments. arg_exprs.append(ex_call( - ast.Attribute(ex_literal(u''), b'join', ast.Load()), + ast.Attribute(ex_literal(u''), 'join', ast.Load()), [ex_call( - b'map', + 'map', [ - ex_rvalue(b'unicode'), + ex_rvalue('unicode'), ast.List(subexprs, ast.Load()), ] )], diff --git a/beetsplug/scrub.py b/beetsplug/scrub.py index 66815ee31..ed4040d5b 100644 --- a/beetsplug/scrub.py +++ b/beetsplug/scrub.py @@ -26,21 +26,21 @@ from beets import config from beets import mediafile _MUTAGEN_FORMATS = { - b'asf': b'ASF', - b'apev2': b'APEv2File', - b'flac': b'FLAC', - b'id3': b'ID3FileType', - b'mp3': b'MP3', - b'mp4': b'MP4', - b'oggflac': b'OggFLAC', - b'oggspeex': b'OggSpeex', - b'oggtheora': b'OggTheora', - b'oggvorbis': b'OggVorbis', - b'oggopus': b'OggOpus', - b'trueaudio': b'TrueAudio', - b'wavpack': b'WavPack', - b'monkeysaudio': b'MonkeysAudio', - b'optimfrog': b'OptimFROG', + 'asf': 'ASF', + 'apev2': 'APEv2File', + 'flac': 'FLAC', + 'id3': 'ID3FileType', + 'mp3': 'MP3', + 'mp4': 'MP4', + 'oggflac': 'OggFLAC', + 'oggspeex': 'OggSpeex', + 'oggtheora': 'OggTheora', + 'oggvorbis': 'OggVorbis', + 'oggopus': 'OggOpus', + 'trueaudio': 'TrueAudio', + 'wavpack': 'WavPack', + 'monkeysaudio': 'MonkeysAudio', + 'optimfrog': 'OptimFROG', } @@ -78,7 +78,7 @@ class ScrubPlugin(BeetsPlugin): """ classes = [] for modname, clsname in _MUTAGEN_FORMATS.items(): - mod = __import__(b'mutagen.{0}'.format(modname), + mod = __import__('mutagen.{0}'.format(modname), fromlist=[clsname]) classes.append(getattr(mod, clsname)) return classes diff --git a/test/test_plugins.py b/test/test_plugins.py index c1a83ec21..421432909 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -323,9 +323,9 @@ class ListenersTest(unittest.TestCase, TestHelper): class DummyPlugin(plugins.BeetsPlugin): def __init__(self): super(DummyPlugin, self).__init__() - self.foo = Mock(__name__=b'foo') + self.foo = Mock(__name__='foo') self.register_listener('event_foo', self.foo) - self.bar = Mock(__name__=b'bar') + self.bar = Mock(__name__='bar') self.register_listener('event_bar', self.bar) d = DummyPlugin()