From 7240a826bc7e2a038501b4c5672442590cdc451f Mon Sep 17 00:00:00 2001 From: Rainer Hihn Date: Wed, 24 Apr 2019 20:05:26 +0200 Subject: [PATCH] Fixed PaddedFloat-type and set precision to 8 --- beets/dbcore/types.py | 4 ++-- beetsplug/acousticbrainz.py | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/beets/dbcore/types.py b/beets/dbcore/types.py index bc923f747..fe83f68b2 100644 --- a/beets/dbcore/types.py +++ b/beets/dbcore/types.py @@ -183,7 +183,7 @@ class Float(Type): return u'{0:.1f}'.format(value or 0.0) -class PaddedFloat(Integer): +class PaddedFloat(Float): """A float field that is formatted with a given number of digits, padded with zeroes. """ @@ -191,7 +191,7 @@ class PaddedFloat(Integer): self.digits = digits def format(self, value): - return u'{0:0{1}d}'.format(value or 0, self.digits) + return u'{0:.{1}f}'.format(value or 0, self.digits) class NullFloat(Float): diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 11a67eadd..cdd6a6b83 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -107,25 +107,25 @@ ABSCHEME = { class AcousticPlugin(plugins.BeetsPlugin): item_types = { - 'average_loudness': types.PaddedFloat(6), - 'chords_changes_rate': types.PaddedFloat(6), + 'average_loudness': types.PaddedFloat(8), + 'chords_changes_rate': types.PaddedFloat(8), 'chords_key': types.STRING, - 'chords_number_rate': types.PaddedFloat(6), + 'chords_number_rate': types.PaddedFloat(8), 'chords_scale': types.STRING, - 'danceable': types.PaddedFloat(6), + 'danceable': types.PaddedFloat(8), 'gender': types.STRING, 'genre_rosamerica': types.STRING, 'initial_key': types.STRING, - 'key_strength': types.PaddedFloat(6), - 'mood_acoustic': types.PaddedFloat(6), - 'mood_aggressive': types.PaddedFloat(6), - 'mood_electronic': types.PaddedFloat(6), - 'mood_happy': types.PaddedFloat(6), - 'mood_party': types.PaddedFloat(6), - 'mood_relaxed': types.PaddedFloat(6), - 'mood_sad': types.PaddedFloat(6), - 'rhythm': types.PaddedFloat(6), - 'tonal': types.PaddedFloat(6), + 'key_strength': types.PaddedFloat(8), + 'mood_acoustic': types.PaddedFloat(8), + 'mood_aggressive': types.PaddedFloat(8), + 'mood_electronic': types.PaddedFloat(8), + 'mood_happy': types.PaddedFloat(8), + 'mood_party': types.PaddedFloat(8), + 'mood_relaxed': types.PaddedFloat(8), + 'mood_sad': types.PaddedFloat(8), + 'rhythm': types.PaddedFloat(8), + 'tonal': types.PaddedFloat(8), 'voice_instrumental': types.STRING, }