mirror of
https://github.com/beetbox/beets.git
synced 2026-02-09 08:52:30 +01:00
zero-pad date values in path formats (#282)
This commit is contained in:
parent
93678307ef
commit
b44195853c
3 changed files with 18 additions and 4 deletions
|
|
@ -317,7 +317,11 @@ def sanitize_for_path(value, pathmod, key=None):
|
|||
if sep:
|
||||
value = value.replace(sep, u'_')
|
||||
elif key in ('track', 'tracktotal', 'disc', 'disctotal'):
|
||||
# pad with zeros
|
||||
# Pad indices with zeros.
|
||||
value = u'%02i' % value
|
||||
elif key == 'year':
|
||||
value = u'%04i' % value
|
||||
elif key in ('month', 'day'):
|
||||
value = u'%02i' % value
|
||||
elif key == 'bitrate':
|
||||
# Bitrate gets formatted as kbps.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ This release focuses on making beets' path formatting vastly more powerful.
|
|||
files (when tag-writing is enabled).
|
||||
* Add a message when skipping directories during an incremental import.
|
||||
* Ignore FUSE's shadow files when importing.
|
||||
* Date values in path formats (``$year``, ``$month``, and ``$day``) are now
|
||||
appropriately zero-padded.
|
||||
* Removed the ``--path-format`` global flag for ``beet``.
|
||||
* Removed the ``lastid`` plugin, which was deprecated in the previous version.
|
||||
|
||||
|
|
|
|||
|
|
@ -165,15 +165,23 @@ class DestinationTest(unittest.TestCase):
|
|||
def test_destination_pads_some_indices(self):
|
||||
self.lib.directory = 'base'
|
||||
self.lib.path_formats = {'default': '$track $tracktotal ' \
|
||||
'$disc $disctotal $bpm $year'}
|
||||
'$disc $disctotal $bpm'}
|
||||
self.i.track = 1
|
||||
self.i.tracktotal = 2
|
||||
self.i.disc = 3
|
||||
self.i.disctotal = 4
|
||||
self.i.bpm = 5
|
||||
self.i.year = 6
|
||||
self.assertEqual(self.lib.destination(self.i),
|
||||
np('base/01 02 03 04 5 6'))
|
||||
np('base/01 02 03 04 5'))
|
||||
|
||||
def test_destination_pads_date_values(self):
|
||||
self.lib.directory = 'base'
|
||||
self.lib.path_formats = {'default': '$year-$month-$day'}
|
||||
self.i.year = 1
|
||||
self.i.month = 2
|
||||
self.i.day = 3
|
||||
self.assertEqual(self.lib.destination(self.i),
|
||||
np('base/0001-02-03'))
|
||||
|
||||
def test_destination_escapes_slashes(self):
|
||||
self.i.album = 'one/two'
|
||||
|
|
|
|||
Loading…
Reference in a new issue