/[cvs]/nfo/projects/netfraggle/bin/FraggleCtlModules.py
ViewVC logotype

Contents of /nfo/projects/netfraggle/bin/FraggleCtlModules.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Tue Sep 21 18:04:42 2004 UTC (20 years, 2 months ago) by xabbu
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +23 -10 lines
File MIME type: text/x-python
+ added function dispatch and utilfunctions for dispatching contents to the modules

1 import os
2 import string
3
4 import fraggleParserXML
5 from fraggleEngine import *
6
7
8 def create(parent):
9 return FraggleCtlModules(parent)
10
11 class FraggleCtlModules:
12
13 def __init__(self,parent):
14 self.modules = self.ScanModules()
15 self.engine = parent
16 self.modfile = os.path.join(self.engine.getDefaultDir(), 'modules.xml')
17 pass
18
19 def SaveModules(self,lmodules):
20 fraggleXml = fraggleParserXML.create(self)
21 fraggleXml.marshalXML(lmodules,self.modfile)
22
23 def LoadModules(self):
24 fraggleXml = fraggleParserXML.create(self)
25 return fraggleXml.unmarshalXML(self.modfile)
26
27 def SetViewport(self,viewport):
28 self.viewport = viewport
29
30 def Dispatch(self,seldata,seltype):
31 print "Type: "+seltype
32 for i in self.modules:
33 print "Module: "+i
34 if i == seltype:
35 module = self.modules[i]
36 moduleInstance = module.create(self.viewport)
37 moduleInstance.load_content(seldata['3'])
38 print module
39
40 def ScanModules(self):
41 os.chdir('..')
42 sys.path.append(os.path.join(os.getcwd(),'modules'))
43 self.dir = os.listdir(os.path.join(os.getcwd(),'modules'))
44 for i in self.dir:
45 self.dir[self.dir.index(i)] = string.rstrip(i,'.py')
46
47 #print self.dir
48
49 if len(self.dir) != 0:
50 try:
51 for i in self.dir:
52 if string.find(i,'CVS') == -1 and string.find(i,'.pyc') == -1:
53 #print i
54 try:
55 fmodules[i] = __import__(i)
56 except NameError:
57 fmodules = {i:__import__(i)}
58 #print fmodules
59 try:
60 print fmodules
61 return fmodules
62 except UnboundLocalError:
63 return None
64 except ImportError:
65 pass
66 return None
67
68
69

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed