From 6f77169ad2b0ff401f9b622203599ee09d89137b Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 11 May 2013 13:24:23 -0700 Subject: [PATCH] itime (#264): name change I changed the "itime" field to "added" and the %format function to %time. --- beets/library.py | 14 +++++++------- beets/ui/commands.py | 5 ++++- test/rsrc/test.blb | Bin 7168 -> 7168 bytes test/test_db.py | 10 +++++----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/beets/library.py b/beets/library.py index 7e1bccd73..e19c4682f 100644 --- a/beets/library.py +++ b/beets/library.py @@ -104,7 +104,7 @@ ITEM_FIELDS = [ ('bitdepth', 'int', False, True), ('channels', 'int', False, True), ('mtime', 'int', False, False), - ('itime', 'datetime', False, False), + ('added', 'datetime', False, False), ] ITEM_KEYS_WRITABLE = [f[0] for f in ITEM_FIELDS if f[3] and f[2]] ITEM_KEYS_META = [f[0] for f in ITEM_FIELDS if f[3]] @@ -116,7 +116,7 @@ ITEM_KEYS = [f[0] for f in ITEM_FIELDS] ALBUM_FIELDS = [ ('id', 'integer primary key', False), ('artpath', 'blob', False), - ('itime', 'datetime', True), + ('added', 'datetime', True), ('albumartist', 'text', True), ('albumartist_sort', 'text', True), @@ -203,7 +203,7 @@ def format_for_path(value, key=None, pathmod=None): elif key == 'samplerate': # Sample rate formatted as kHz. value = u'%ikHz' % ((value or 0) // 1000) - elif key in ('itime', 'mtime'): + elif key in ('added', 'mtime'): # Times are formatted to be human-readable. value = time.strftime(beets.config['time_format'].get(unicode), time.localtime(value)) @@ -1295,7 +1295,7 @@ class Library(BaseLibrary): # Item manipulation. def add(self, item, copy=False): - item.itime = time.time() + item.added = time.time() if copy: self.move(item, copy=True) @@ -1510,7 +1510,7 @@ class Library(BaseLibrary): # When adding an album and its items for the first time, the # items do not yet have a timestamp. - album_values['itime'] = time.time() + album_values['added'] = time.time() with self.transaction() as tx: sql = 'INSERT INTO albums (%s) VALUES (%s)' % \ @@ -1826,8 +1826,8 @@ class DefaultTemplateFunctions(object): return unidecode(s) @staticmethod - def tmpl_format(s, format): - """Format the import time to any format according to time.strfime() + def tmpl_time(s, format): + """Format a time value using `strftime`. """ cur_fmt = beets.config['time_format'].get(unicode) return time.strftime(format, time.strptime(s, cur_fmt)) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 6a2669f49..8954b1c7c 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1014,7 +1014,10 @@ def _convert_type(key, value, album=False): def modify_items(lib, mods, query, write, move, album, confirm): """Modifies matching items according to key=value assignments.""" # Parse key=value specifications into a dictionary. - allowed_keys = library.ALBUM_KEYS if album else library.ITEM_KEYS_WRITABLE + ['itime'] + if album: + allowed_keys = library.ALBUM_KEYS + else: + allowed_keys = library.ITEM_KEYS_WRITABLE + ['added'] fsets = {} for mod in mods: key, value = mod.split('=', 1) diff --git a/test/rsrc/test.blb b/test/rsrc/test.blb index bd92dd6fdb4068e0254e0b61205f8694d6ad33ae..22c621da507ed223fa32f540116c9d7850968444 100644 GIT binary patch delta 160 zcmZp$Xt0|#FUiO6or(;lGKvS+*D0opjJl4%?ym2Hw$vC jWaMh`VqzDUlw|D4-+Wfkh)EDb!)8ViHkQq762F)MIr1f2 delta 144 zcmZp$Xt0(Lo3NJ}a%1O;ENp1IKWCw}#Rc>sEVVe9v$Y%2)K3zs`O