Began new library scanning code
The new scanning code will use FSTrees() to find paths. I hope it will be easy to make a scanning progress bar with the new system.
This commit is contained in:
parent
bafa6e7e8a
commit
b1ae9fd878
|
@ -14,41 +14,56 @@ visible = None
|
|||
filtered = False
|
||||
|
||||
def reset():
|
||||
from libsaria.trees import FSTree
|
||||
from tree import DLTree
|
||||
from index import Index
|
||||
|
||||
global index
|
||||
global tracks
|
||||
global fs_tree
|
||||
global tag_tree
|
||||
global sources
|
||||
global next_id
|
||||
global visible
|
||||
|
||||
sources = FSTree()
|
||||
|
||||
fs_tree = DLTree()
|
||||
tag_tree = DLTree()
|
||||
index = Index()
|
||||
tracks = dict()
|
||||
next_id = 0
|
||||
size = 0
|
||||
sources = []
|
||||
visible = set()
|
||||
save()
|
||||
|
||||
def load():
|
||||
global fs_tree
|
||||
global tag_tree
|
||||
global index
|
||||
global tracks
|
||||
#global fs_tree
|
||||
#global tag_tree
|
||||
#global index
|
||||
#global tracks
|
||||
global next_id
|
||||
global sources
|
||||
global size
|
||||
global songs
|
||||
objects = libsaria.data.load("library", ".dl_tree")
|
||||
if objects == None or len(objects) != 6:
|
||||
#global size
|
||||
#global songs
|
||||
objects = libsaria.data.load("library", ".lib")
|
||||
if objects == None or len(objects) != 2:
|
||||
#if objects == None or len(objects) != 6:
|
||||
reset()
|
||||
return
|
||||
(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
||||
(sources, next_id) = objects
|
||||
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
||||
libsaria.event.start("POSTLIBLOAD")
|
||||
|
||||
def save():
|
||||
libsaria.data.save(
|
||||
(fs_tree, tag_tree, index, tracks, next_id, size),
|
||||
"library", ".dl_tree")
|
||||
global sources
|
||||
libsaria.data.save( (sources, next_id), "library", ".lib")
|
||||
|
||||
def walk():
|
||||
return []
|
||||
for tag in tag_tree.walk_forwards():
|
||||
yield tag[3]
|
||||
#yield tag[3]
|
||||
pass
|
||||
|
||||
def file_to_id(file):
|
||||
global fs_tree
|
||||
|
@ -64,7 +79,7 @@ def get_attrs(id, *attrs):
|
|||
res = []
|
||||
rec = tracks.get(id, None)
|
||||
if rec == None:
|
||||
return None
|
||||
return [0] * len(attrs)
|
||||
|
||||
get = rec.__dict__.get
|
||||
tags = rec.tags.walk_backwards()
|
||||
|
@ -126,3 +141,18 @@ def is_visible(id):
|
|||
return True
|
||||
else:
|
||||
return id in visible
|
||||
|
||||
def add_source(path):
|
||||
global sources
|
||||
sources.insert_path(path)
|
||||
|
||||
def scan(path):
|
||||
add_source(path)
|
||||
update()
|
||||
save()
|
||||
|
||||
def update():
|
||||
global sources
|
||||
sep = libsaria.path.sep
|
||||
for path in sources.walk_paths():
|
||||
print path
|
||||
|
|
Loading…
Reference in New Issue