43 lines
672 B
Python
43 lines
672 B
Python
# Bryan Schumaker (8/8/2010)
|
|
|
|
import libsaria
|
|
import table
|
|
|
|
class Collection:
|
|
def __init__(self):
|
|
self.table = table.Table()
|
|
|
|
|
|
def scan(self, path):
|
|
print "Scanning path:", path
|
|
self.clear()
|
|
self.update(path)
|
|
|
|
|
|
def clear(self):
|
|
print "Erasing collection ... "
|
|
|
|
|
|
def insert(self, file):
|
|
tags = file.tag()
|
|
id = self.table.insert(tags)
|
|
print id, tags
|
|
|
|
|
|
|
|
def update(self, path):
|
|
FileRef = libsaria.collection.FileRef
|
|
join = libsaria.path.join
|
|
|
|
for root,dirs,files in libsaria.path.walk(path):
|
|
for file in files:
|
|
file = join(root,file)
|
|
try:
|
|
tagfile = FileRef(file)
|
|
self.insert(tagfile)
|
|
except Exception,e:
|
|
print e
|
|
|
|
|
|
|