def __init__(self, name="", location="", pickle_attrs=[], loadfirst=False): """ Sets up the trackDB. """ # ensure that the DB is always loaded before any tracks are, # otherwise internal values are not loaded and may be lost/corrupted if loadfirst and Track._get_track_count() != 0: raise RuntimeError( ("Internal error! %d tracks already loaded, " + "TrackDB must be loaded first!") % Track._get_track_count()) self.name = name self.location = location self._dirty = False self.tracks = {} # key is always URI of the track self.pickle_attrs = pickle_attrs self.pickle_attrs += ['tracks', 'name', '_key'] self._saving = False self._key = 0 self._dbversion = 2.0 self._dbminorversion = 0 self._deleted_keys = [] if location: self.load_from_location() self._timeout_save()
def __init__(self, name="", location="", pickle_attrs=[], loadfirst=False): """ Sets up the trackDB. """ # ensure that the DB is always loaded before any tracks are, # otherwise internal values are not loaded and may be lost/corrupted if loadfirst and Track._get_track_count() != 0: raise RuntimeError(("Internal error! %d tracks already loaded, " + "TrackDB must be loaded first!") % Track._get_track_count()) self.name = name self.location = location self._dirty = False self.tracks = {} self.pickle_attrs = pickle_attrs self.pickle_attrs += ['tracks', 'name', '_key'] self._saving = False self._key = 0 self._dbversion = 2.0 self._dbminorversion = 0 self._deleted_keys = [] if location: self.load_from_location() self._timeout_save()