--- nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/01 21:43:30 1.1 +++ nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/05 12:17:20 1.5 @@ -1,4 +1,5 @@ import os +import string import fraggleParserXML from fraggleEngine import * @@ -10,14 +11,46 @@ 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 ScanModules(self): os.chdir('..') 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') + + import re + regexp = re.compile('CVS$') + + #print self.dir + + if len(self.dir) != 0: + try: + for i in self.dir: + if regexp.match(i) == None: + try: + fmodules[i] = i + except NameError: + fmodules = {i:i} + #print fmodules + try: + return fmodules + except UnboundLocalError: + return None + except ImportError: + pass + return None + \ No newline at end of file