Tags in DLValTree

I store the tags in a doubly-linked value tree from now on.
This commit is contained in:
Bryan Schumaker 2010-11-10 22:47:01 -05:00
parent 88ca239a53
commit cd78355b74
2 changed files with 21 additions and 16 deletions

View File

@ -22,12 +22,12 @@ badfiles = set()
ttable = dict()
for s in string.punctuation:
ttable[ord(s)] = ""
ttable[ord(s)] = u""
for s in string.lowercase:
ttable[ord(s)] = ord(s) - 32
def reset():
from libsaria.trees import FSTree, DLFSTree
from libsaria.trees import FSTree, DLFSTree, DLValTree
from tree import DLTree
from index import Index
@ -41,7 +41,7 @@ def reset():
sources = FSTree()
fs_tree = DLFSTree()
tag_tree = DLTree()
tag_tree = DLValTree()
index = Index()
tracks = dict()
size = 0
@ -49,32 +49,30 @@ def reset():
#save()
def load():
#global fs_tree
#global tag_tree
global fs_tree
global tag_tree
#global index
global tracks
global sources
#global size
#global songs
reset()
objects = libsaria.data.load("library", ".lib")
if objects == None or len(objects) != 3:
if objects == None or len(objects) != 4:
#if objects == None or len(objects) != 6:
reset()
return
(sources, tracks) = objects
(sources, tracks, fs_tree, tag_tree) = objects
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
libsaria.event.start("POSTLIBLOAD")
def save():
global sources
libsaria.data.save( (sources, tracks), "library", ".lib")
libsaria.data.save( (sources, tracks, fs_tree, tag_tree),
"library", ".lib")
def walk():
return []
for tag in tag_tree.walk_forwards():
#yield tag[3]
pass
for tag in tag_tree.walk():
yield tag[3]
def file_to_id(file):
global fs_tree
@ -166,17 +164,24 @@ def insert_track(path, ref):
global tracks
global ttable
global fs_tree
global tag_tree
tags = ref.tag()
audio = ref.audioProperties()
id = os.stat(path).st_ino
ino = os.stat(path).st_ino
track = Track(tags, audio)
artist = tags.artist or u"Unknown Artist"
album = tags.album or u"Unknown Album"
title = tags.title or u"Unknown Title"
fs = fs_tree.insert_path(path)
tag = tag_tree.insert( [artist.translate(ttable),
album.translate(ttable),
title.translate(ttable), ino],
[artist, album, title, ino]
)
track.fs = fs
tracks[id] = track
track.tags = tag
tracks[ino] = track
def update_path(path):
global badfiles

View File

@ -21,4 +21,4 @@ class Track:
self.lenstr = lenstr
self.fs = None
#self.tags = None
self.tags = None