Commits

Adrian Sampson committed 6d38515

itime (#264): name change

I changed the "itime" field to "added" and the %format function to %time.

  • Participants
  • Parent commits 1a85528

Comments (0)

Files changed (4)

     ('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]]
 ALBUM_FIELDS = [
     ('id',      'integer primary key', False),
     ('artpath', 'blob',                False),
-    ('itime',   'datetime',            True),
+    ('added',   'datetime',            True),
 
     ('albumartist',        'text', True),
     ('albumartist_sort',   'text', True),
     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))
     # Item manipulation.
 
     def add(self, item, copy=False):
-        item.itime = time.time()
+        item.added = time.time()
         if copy:
             self.move(item, copy=True)
 
 
         # 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)' % \
         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))

beets/ui/commands.py

 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)

test/rsrc/test.blb

Binary file modified.
         self.assertEqual(val, u'12kHz')
 
     def test_component_sanitize_datetime(self):
-        val = beets.library.format_for_path(1368302461.210265, 'itime',
+        val = beets.library.format_for_path(1368302461.210265, 'added',
                                             posixpath)
         self.assertTrue(val.startswith('2013'))
 
         super(ImportTimeTest, self).setUp()
         self.lib = beets.library.Library(':memory:')
 
-    def test_itime_for_album(self):
+    def added(self):
         self.track = item()
         self.album = self.lib.add_album((self.track,))
-        self.assertGreater(self.album.itime, 0)
-        self.assertGreater(self.track.itime, 0)
+        self.assertGreater(self.album.added, 0)
+        self.assertGreater(self.track.added, 0)
 
     def test_atime_for_singleton(self):
         self.singleton = item()
         self.lib.add(self.singleton)
-        self.assertGreater(self.singleton.itime, 0)
+        self.assertGreater(self.singleton.added, 0)
 
 def suite():
     return unittest.TestLoader().loadTestsFromName(__name__)