66 lines
1.1 KiB
Python
66 lines
1.1 KiB
Python
# This is a simple test plugin, to make sure everything is working
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Jan 1, 2010 6:33:06 PM$"
|
|
|
|
|
|
global name, app, type, path, opt
|
|
name = "create"
|
|
app = "ocarina"
|
|
type = "core"
|
|
path = ""
|
|
opt = []
|
|
|
|
from bt.message import write
|
|
from bt.file import *
|
|
from tools import database
|
|
from manager import manager
|
|
import settings
|
|
|
|
|
|
# Called every time the plugin is enabled
|
|
def open():
|
|
if settings.has("curlib") == False:
|
|
settings.set("curlib",-1)
|
|
|
|
|
|
# Called every time the plugin is stopped
|
|
def close():
|
|
pass
|
|
|
|
|
|
def help():
|
|
return "Used to create a new library"
|
|
|
|
|
|
def library(args):
|
|
name = "Default"
|
|
root = ""
|
|
if len(args) >= 2:
|
|
name = args[0]
|
|
#if len(args) >= 2:
|
|
space = ' '
|
|
root = expandPath( space.join(args[1:]) )
|
|
else:
|
|
return
|
|
|
|
if checkDir(root) == False:
|
|
return
|
|
|
|
# Insert the library into the database
|
|
database.open()
|
|
next = database.count('library')
|
|
settings.replace("curlib",next)
|
|
database.insert('library',(next,name,root) )
|
|
database.close()
|
|
|
|
manager.run("scan",[root])
|
|
|
|
|
|
# Called when the plugin needs to perform some action
|
|
def run(args=None):
|
|
l = len(args)
|
|
if args[0] == "library":
|
|
library(args[1:])
|
|
|