--- nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/01 21:43:30 1.1 +++ nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/21 18:04:42 1.6 @@ -1,4 +1,5 @@ import os +import string import fraggleParserXML from fraggleEngine import * @@ -10,14 +11,59 @@ class FraggleCtlModules: def __init__(self,parent): - self.ScanModules() + self.modules = self.ScanModules() self.engine = parent + self.modfile = os.path.join(self.engine.getDefaultDir(), 'modules.xml') pass + def SaveModules(self,lmodules): + fraggleXml = fraggleParserXML.create(self) + fraggleXml.marshalXML(lmodules,self.modfile) + + def LoadModules(self): + fraggleXml = fraggleParserXML.create(self) + return fraggleXml.unmarshalXML(self.modfile) + + def SetViewport(self,viewport): + self.viewport = viewport + + def Dispatch(self,seldata,seltype): + print "Type: "+seltype + for i in self.modules: + print "Module: "+i + if i == seltype: + module = self.modules[i] + moduleInstance = module.create(self.viewport) + moduleInstance.load_content(seldata['3']) + print module + def ScanModules(self): os.chdir('..') + sys.path.append(os.path.join(os.getcwd(),'modules')) self.dir = os.listdir(os.path.join(os.getcwd(),'modules')) - print self.dir - pass + for i in self.dir: + self.dir[self.dir.index(i)] = string.rstrip(i,'.py') + + #print self.dir + + if len(self.dir) != 0: + try: + for i in self.dir: + if string.find(i,'CVS') == -1 and string.find(i,'.pyc') == -1: + #print i + try: + fmodules[i] = __import__(i) + except NameError: + fmodules = {i:__import__(i)} + #print fmodules + try: + print fmodules + return fmodules + except UnboundLocalError: + return None + except ImportError: + pass + return None + \ No newline at end of file