diff --git a/src/core/ct/db.py b/src/core/ct/db.py index 0aef95f9..ccd387e3 100644 --- a/src/core/ct/db.py +++ b/src/core/ct/db.py @@ -48,6 +48,23 @@ def init(): def newlib(name,path): - ins = sql.Insert('library',[None,name,path]) - ins.execute() - ins.commit() \ No newline at end of file + 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] ) \ No newline at end of file diff --git a/src/core/library.py b/src/core/library.py index 5a88cd95..340bb017 100644 --- a/src/core/library.py +++ b/src/core/library.py @@ -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:])