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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations)
Tue Sep 21 18:04:42 2004 UTC (19 years, 9 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 xabbu 1.1 import os
2 xabbu 1.2 import string
3 xabbu 1.1
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 xabbu 1.3 self.modules = self.ScanModules()
15 xabbu 1.1 self.engine = parent
16 xabbu 1.5 self.modfile = os.path.join(self.engine.getDefaultDir(), 'modules.xml')
17 xabbu 1.1 pass
18    
19 xabbu 1.5 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 xabbu 1.6
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 xabbu 1.5
40 xabbu 1.1 def ScanModules(self):
41     os.chdir('..')
42 xabbu 1.6 sys.path.append(os.path.join(os.getcwd(),'modules'))
43 xabbu 1.1 self.dir = os.listdir(os.path.join(os.getcwd(),'modules'))
44 xabbu 1.2 for i in self.dir:
45 xabbu 1.3 self.dir[self.dir.index(i)] = string.rstrip(i,'.py')
46    
47 xabbu 1.5 #print self.dir
48 xabbu 1.2
49     if len(self.dir) != 0:
50     try:
51     for i in self.dir:
52 xabbu 1.6 if string.find(i,'CVS') == -1 and string.find(i,'.pyc') == -1:
53     #print i
54 xabbu 1.5 try:
55 xabbu 1.6 fmodules[i] = __import__(i)
56 xabbu 1.5 except NameError:
57 xabbu 1.6 fmodules = {i:__import__(i)}
58 xabbu 1.5 #print fmodules
59 xabbu 1.6 try:
60     print fmodules
61     return fmodules
62     except UnboundLocalError:
63     return None
64 xabbu 1.2 except ImportError:
65     pass
66 xabbu 1.3 return None
67    
68 xabbu 1.1
69    

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