From 717d0eeca3bd05cf483e3622398569a8736cfa91 Mon Sep 17 00:00:00 2001 From: bjschuma Date: Sun, 27 Dec 2009 20:32:41 -0500 Subject: [PATCH] Can scan and add a path to the library --- src/core/ocarina.py | 3 ++- src/core/scan.py | 40 +++++++++++++++++++++++++++++++++++++++ src/core/tools/library.py | 33 +++++++++++++++----------------- 3 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 src/core/scan.py diff --git a/src/core/ocarina.py b/src/core/ocarina.py index 3e86a176..6e4ec201 100644 --- a/src/core/ocarina.py +++ b/src/core/ocarina.py @@ -19,12 +19,13 @@ from bt.message import write import bt.proc from manager import manager +from tools import library + # Called every time the plugin is enabled def open(): write("Ocarina has been started",True) bt.proc.setname("Ocarina 2") - #write("Example plugin has been changed",True) # Called every time the plugin is stopped diff --git a/src/core/scan.py b/src/core/scan.py new file mode 100644 index 00000000..a34af2cd --- /dev/null +++ b/src/core/scan.py @@ -0,0 +1,40 @@ +# This is a simple test plugin, to make sure everything is working + +__author__="bjschuma" +__date__ ="$Dec 27, 2009 8:07:18 PM$" + + +global name, app, type, path, opt +name = "test" +app = "scion" +type = "core" +path = "" +opt = [] + +from bt.message import write +from bt.file import expandPath +from tools.library import library + + +# Called every time the plugin is enabled +def open(): + pass + #write("Example plugin has been started",True) + #write("Example plugin has been changed",True) + + +# Called every time the plugin is stopped +def close(): + pass + #write("Example plugin has been stopped",True) + + +# Called when the plugin needs to perform some action +def run(args=None): + if args == None: + return + + space = ' ' + path = space.join(args) + library.scan(expandPath(path)) + pass diff --git a/src/core/tools/library.py b/src/core/tools/library.py index 8caa1fe9..1f6063ae 100644 --- a/src/core/tools/library.py +++ b/src/core/tools/library.py @@ -4,27 +4,24 @@ __author__="bjschuma" __date__ ="$Dec 21, 2009 8:43:01 PM$" -global name, app, type, path, opt -name = "library" -app = "ocarina" -type = "core" -path = "" -opt = [] - +from bt.file import * from bt.message import write -# Called every time the plugin is enabled -def open(): - write("Example plugin has been started",True) - #write("Example plugin has been changed",True) +class Library: + def __init__(self): + self.files = [] -# Called every time the plugin is stopped -def close(): - write("Example plugin has been stopped",True) + def scan(self, dir): + files = ls(dir) + for file in files: + path = join(dir,file) + if checkDir(path)==True: + self.scan(path) + else: + write(path,True) + self.files += [path] - -# Called when the plugin needs to perform some action -def run(args=None): - pass +global library +library = Library()