Can remove a created library

This commit is contained in:
bjschuma 2010-01-30 14:41:49 -05:00
parent e5edd7a9dd
commit 1d0a216c12
2 changed files with 36 additions and 5 deletions

View File

@ -48,6 +48,23 @@ def init():
def newlib(name,path):
ins = sql.Insert('library',[None,name,path])
ins.execute()
ins.commit()
try:
ins = sql.Insert('library',[None,name,path])
ins.execute()
except:
pass
def rmlib(name):
rm = sql.Remove("library","name='"+name+"'")
rm.execute()
def listlib():
sel = sql.Select("*","library")
result = sel.execute().fetchall()
write("Id Name Path")
write("------------------")
for row in result:
write( str(row[0]) + " " +
row[1] + " " + row[2] )

View File

@ -14,7 +14,7 @@ class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = "Used to access various parts of the library"
self.usage = "library [create]"
self.usage = "library [create, list]"
def create(self,args):
@ -29,10 +29,24 @@ class Plugin(plugin.Plugin):
db.newlib(name,path)
def remove(self,args):
usage = "Usage: library remove name"
if len(args) < 1:
write(usage)
return
name = args[0]
db.rmlib(name)
def run(self, args=None):
if (args==None) or (len(args)==0):
write(self.usage)
return
if args[0] == "create":
self.create(args[1:])
elif args[0] == "list":
db.listlib()
elif args[0] == "remove":
self.remove(args[1:])