trackdb: Rename LibraryPath.path to LibraryPath.name
So it matches the name of the field in the Tag class Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
219a3184b0
commit
51a1078b4d
|
@ -23,7 +23,7 @@ def add_path(path):
|
|||
|
||||
def get_library(path):
|
||||
for lib in library_paths:
|
||||
if lib.path == pathlib.Path(path):
|
||||
if lib.name == pathlib.Path(path):
|
||||
return lib
|
||||
return None
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ TrackRemoved = Tracks.Removed
|
|||
|
||||
class LibraryPath:
|
||||
def __init__(self, path):
|
||||
self.path = pathlib.Path(path)
|
||||
self.name = pathlib.Path(path)
|
||||
self.tracks = dict()
|
||||
self.thread = None
|
||||
self.lock = threading.Lock()
|
||||
|
@ -27,7 +27,7 @@ class LibraryPath:
|
|||
return state
|
||||
|
||||
def __setstate__(self, state):
|
||||
self.path = state["path"]
|
||||
self.name = state["name"]
|
||||
self.tracks = state["tracks"]
|
||||
self.thread = None
|
||||
self.lock = threading.Lock()
|
||||
|
@ -38,7 +38,7 @@ class LibraryPath:
|
|||
del self.tracks[trak.trackid]
|
||||
|
||||
track_set = set([ t.filepath() for t in Tracks.list_tracks(self) ])
|
||||
files = [ f for f in self.path.rglob("*") if f.is_file() and f not in track_set ]
|
||||
files = [ f for f in self.name.rglob("*") if f.is_file() and f not in track_set ]
|
||||
for f in files:
|
||||
if (track := Tracks.allocate(self, f)) != None:
|
||||
with self.lock:
|
||||
|
@ -46,7 +46,7 @@ class LibraryPath:
|
|||
self.thread = None
|
||||
|
||||
def add_track(self, *components):
|
||||
return self.__add_track__(self.path / pathlib.Path(*components))
|
||||
return self.__add_track__(self.name / pathlib.Path(*components))
|
||||
|
||||
def scan(self):
|
||||
if not self.thread:
|
||||
|
|
|
@ -33,7 +33,7 @@ class TestLibraryPath(unittest.TestCase):
|
|||
|
||||
def test_library_path_init(self):
|
||||
lib = library.LibraryPath(test_tracks)
|
||||
self.assertEqual(lib.path, test_tracks)
|
||||
self.assertEqual(lib.name, test_tracks)
|
||||
self.assertEqual(lib.tracks, { })
|
||||
self.assertIsNone(lib.thread)
|
||||
self.assertIsInstance(lib.lock, type(threading.Lock()))
|
||||
|
@ -43,8 +43,8 @@ class TestLibraryPath(unittest.TestCase):
|
|||
lib.scan().join()
|
||||
|
||||
state = lib.__getstate__()
|
||||
self.assertEqual(set(state.keys()), set([ "path", "tracks" ]))
|
||||
self.assertEqual(state["path"], test_tracks)
|
||||
self.assertEqual(set(state.keys()), set([ "name", "tracks" ]))
|
||||
self.assertEqual(state["name"], test_tracks)
|
||||
self.assertEqual(len(state["tracks"]), 12)
|
||||
|
||||
lib.path = None
|
||||
|
@ -53,7 +53,7 @@ class TestLibraryPath(unittest.TestCase):
|
|||
lib.lock = None
|
||||
|
||||
lib.__setstate__(state)
|
||||
self.assertEqual(lib.path, test_tracks)
|
||||
self.assertEqual(lib.name, test_tracks)
|
||||
self.assertEqual(lib.tracks, state["tracks"])
|
||||
self.assertEqual(lib.thread, None)
|
||||
self.assertIsInstance(lib.lock, type(threading.Lock()))
|
||||
|
|
|
@ -9,7 +9,7 @@ TrackUpdated = publisher.Publisher()
|
|||
class Track:
|
||||
def __init__(self, trackid, filepath, library):
|
||||
self.trackid = trackid
|
||||
self.path = filepath.relative_to(library.path)
|
||||
self.path = filepath.relative_to(library.name)
|
||||
self.library = library
|
||||
self.lastplayed = None
|
||||
self.playcount = 0
|
||||
|
@ -57,7 +57,7 @@ class Track:
|
|||
self.year = tags.Year.init_track(self.decade, self.year, self)
|
||||
|
||||
def filepath(self):
|
||||
return self.library.path / self.path
|
||||
return self.library.name / self.path
|
||||
|
||||
def played(self):
|
||||
self.playcount += 1
|
||||
|
|
Loading…
Reference in New Issue