diff --git a/beets/library.py b/beets/library.py index a57ed1642..b1093676f 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1296,11 +1296,11 @@ class DefaultTemplateFunctions(object): return unidecode(s) @staticmethod - def tmpl_time(s, format): + def tmpl_time(s, fmt): """Format a time value using `strftime`. """ cur_fmt = beets.config['time_format'].get(unicode) - return time.strftime(format, time.strptime(s, cur_fmt)) + return time.strftime(fmt, time.strptime(s, cur_fmt)) def tmpl_aunique(self, keys=None, disam=None): """Generate a string that is guaranteed to be unique among all diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 32201f58d..6612ca2cd 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -438,8 +438,8 @@ def summarize_items(items, singleton): summary_parts.append(items[0].format) else: # Enumerate all the formats. - for format, count in format_counts.iteritems(): - summary_parts.append('{0} {1}'.format(format, count)) + for fmt, count in format_counts.iteritems(): + summary_parts.append('{0} {1}'.format(fmt, count)) average_bitrate = sum([item.bitrate for item in items]) / len(items) total_duration = sum([item.length for item in items]) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 2f49b5ef8..352c3c94d 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -49,25 +49,25 @@ def replace_ext(path, ext): return os.path.splitext(path)[0] + b'.' + ext -def get_format(format=None): +def get_format(fmt=None): """Return the command tempate and the extension from the config. """ - if not format: - format = config['convert']['format'].get(unicode).lower() - format = ALIASES.get(format, format) + if not fmt: + fmt = config['convert']['format'].get(unicode).lower() + fmt = ALIASES.get(fmt, fmt) try: - format_info = config['convert']['formats'][format].get(dict) + format_info = config['convert']['formats'][fmt].get(dict) command = format_info['command'] extension = format_info['extension'] except KeyError: raise ui.UserError( u'convert: format {0} needs "command" and "extension" fields' - .format(format) + .format(fmt) ) except ConfigTypeError: - command = config['convert']['formats'][format].get(bytes) - extension = format + command = config['convert']['formats'][fmt].get(bytes) + extension = fmt # Convenience and backwards-compatibility shortcuts. keys = config['convert'].keys() @@ -84,7 +84,7 @@ def get_format(format=None): return (command.encode('utf8'), extension.encode('utf8')) -def should_transcode(item, format): +def should_transcode(item, fmt): """Determine whether the item should be transcoded as part of conversion (i.e., its bitrate is high or it has the wrong format). """ @@ -92,7 +92,7 @@ def should_transcode(item, format): not (item.format.lower() in LOSSLESS_FORMATS): return False maxbr = config['convert']['max_bitrate'].get(int) - return format.lower() != item.format.lower() or \ + return fmt.lower() != item.format.lower() or \ item.bitrate >= 1000 * maxbr @@ -209,9 +209,9 @@ class ConvertPlugin(BeetsPlugin): self._log.info(u'Finished encoding {0}', util.displayable_path(source)) - def convert_item(self, dest_dir, keep_new, path_formats, format, + def convert_item(self, dest_dir, keep_new, path_formats, fmt, pretend=False): - command, ext = get_format(format) + command, ext = get_format(fmt) item, original, converted = None, None, None while True: item = yield (item, original, converted) @@ -224,11 +224,11 @@ class ConvertPlugin(BeetsPlugin): if keep_new: original = dest converted = item.path - if should_transcode(item, format): + if should_transcode(item, fmt): converted = replace_ext(converted, ext) else: original = item.path - if should_transcode(item, format): + if should_transcode(item, fmt): dest = replace_ext(dest, ext) converted = dest @@ -254,7 +254,7 @@ class ConvertPlugin(BeetsPlugin): util.displayable_path(original)) util.move(item.path, original) - if should_transcode(item, format): + if should_transcode(item, fmt): try: self.encode(command, original, converted, pretend) except subprocess.CalledProcessError: @@ -386,8 +386,8 @@ class ConvertPlugin(BeetsPlugin): """Transcode a file automatically after it is imported into the library. """ - format = self.config['format'].get(unicode).lower() - if should_transcode(item, format): + fmt = self.config['format'].get(unicode).lower() + if should_transcode(item, fmt): command, ext = get_format() fd, dest = tempfile.mkstemp('.' + ext) os.close(fd) diff --git a/beetsplug/the.py b/beetsplug/the.py index 3fb16dcf9..538b81245 100644 --- a/beetsplug/the.py +++ b/beetsplug/the.py @@ -30,12 +30,6 @@ FORMAT = u'{0}, {1}' class ThePlugin(BeetsPlugin): - _instance = None - - the = True - a = True - format = u'' - strip = False patterns = [] def __init__(self): diff --git a/test/test_the.py b/test/test_the.py index 1b33c390e..e04db1aec 100644 --- a/test/test_the.py +++ b/test/test_the.py @@ -44,7 +44,6 @@ class ThePluginTest(_common.TestCase): def test_template_function_with_defaults(self): ThePlugin().patterns = [PATTERN_THE, PATTERN_A] - ThePlugin().format = FORMAT self.assertEqual(ThePlugin().the_template_func('The The'), 'The, The') self.assertEqual(ThePlugin().the_template_func('An A'), 'A, An')