diff --git a/beetsplug/info.py b/beetsplug/info.py index b719723bc..854a2441b 100644 --- a/beetsplug/info.py +++ b/beetsplug/info.py @@ -90,17 +90,10 @@ def print_data(data, fmt=None, human_length=True): If no format string `fmt` is passed, the entries on `data` are printed one in each line, with the format 'field: value'. If `fmt` is not `None`, the item is printed according to `fmt`, using the `Item.__format__` machinery. - - If `raw_length` is `True`, the `length` field is displayed using its raw - value (float with the number of seconds and miliseconds). If not, a human - readable form is displayed instead (mm:ss). """ item = data.pop('item', None) if fmt: - # use fmt specified by the user, prettifying length if needed - if human_length and '$length' in fmt: - item['humanlength'] = ui.human_seconds_short(item.length) - fmt = fmt.replace('$length', '$humanlength') + # use fmt specified by the user ui.print_(format(item, fmt)) return @@ -110,10 +103,7 @@ def print_data(data, fmt=None, human_length=True): if isinstance(value, list): formatted[key] = u'; '.join(value) if value is not None: - if human_length and key == 'length': - formatted[key] = ui.human_seconds_short(float(value)) - else: - formatted[key] = value + formatted[key] = value if len(formatted) == 0: return @@ -143,9 +133,6 @@ class InfoPlugin(BeetsPlugin): cmd.parser.add_option('-i', '--include-keys', default=[], action='append', dest='included_keys', help='comma separated list of keys to show') - cmd.parser.add_option('-r', '--raw-length', action='store_true', - default=False, - help='display length as seconds') cmd.parser.add_format_option(target='item') return [cmd] @@ -192,11 +179,11 @@ class InfoPlugin(BeetsPlugin): else: if not first: ui.print_() - print_data(data, opts.format, not opts.raw_length) + print_data(data, opts.format) first = False if opts.summarize: - print_data(summary, human_length=not opts.raw_length) + print_data(summary) def make_key_filter(include): diff --git a/test/test_info.py b/test/test_info.py index 395382b34..aaabed980 100644 --- a/test/test_info.py +++ b/test/test_info.py @@ -107,43 +107,11 @@ class InfoTest(unittest.TestCase, TestHelper): self.assertNotIn(u'title:', out) self.assertIn(u'album: xxxx', out) - def test_length_human_library(self): - item, = self.add_item_fixtures() - item.album = 'loool' - item.length = 123.4 - item.write() - item.store() - - out = self.run_with_output('--library') - self.assertIn(u'length: 2:03', out) - - def test_length_raw_library(self): - item, = self.add_item_fixtures() - item.album = 'loool' - item.length = 123.4 - item.write() - item.store() - - out = self.run_with_output('--library', '--raw-length') - self.assertIn(u'length: 123.4', out) - - def test_length_human_path(self): - path = self.create_mediafile_fixture() - out = self.run_with_output(path) - self.assertIn(u'length: 0:01', out) - self.remove_mediafile_fixtures() - - def test_length_raw_path(self): - path = self.create_mediafile_fixture() - out = self.run_with_output(path, '--raw-length') - self.assertIn(u'length: 1.071', out) - self.remove_mediafile_fixtures() - def test_custom_format(self): self.add_item_fixtures() out = self.run_with_output('--library', '--format', '$track. $title - $artist ($length)') - self.assertEqual(u'02. tïtle 0 - the artist (0:01)\n', out) + self.assertEqual(u'02. tïtle 0 - the artist (1.1)\n', out) def suite():