ocarina/src/core/library.py

53 lines
968 B
Python

# Basic plugin class
__author__="bjschuma"
__date__ ="$Jan 27, 2010 6:16:01 PM$"
from bt import plugin
from bt.file import expandPath
from bt.message import write
from ct import db
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, list]"
def create(self,args):
usage = "Usage: library create name path"
if len(args) < 2:
write(usage)
return
name = args[0]
join = ' '
path = expandPath(join.join(args[1:]))
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:])