From: <ch...@us...> - 2009-05-01 15:27:32
|
Revision: 295 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=295&view=rev Author: chozone Date: 2009-05-01 15:27:26 +0000 (Fri, 01 May 2009) Log Message: ----------- Changed module system, now it works in python 2.6+. Had to rename the VP/modules/playground dir to VP/modules/playgroundObj, because there was a conflict between that dir and VP/modules/playground.py. Modified Paths: -------------- trunk/VP/interface.py trunk/VP/modules/playground.py Added Paths: ----------- trunk/VP/modules/__init__.py trunk/VP/modules/playgroundObj/ trunk/VP/modules/playgroundObj/__init__.py Removed Paths: ------------- trunk/VP/modules/playground/ Modified: trunk/VP/interface.py =================================================================== --- trunk/VP/interface.py 2009-03-31 20:46:57 UTC (rev 294) +++ trunk/VP/interface.py 2009-05-01 15:27:26 UTC (rev 295) @@ -40,9 +40,9 @@ #Load all modules in our memory self.modules = {} for module in os.listdir(getRealDir('modules')): - if module[-3:] == '.py': - realName = os.path.join('modules', module[:-3]) - self.modules[module[:-3]] = __import__(realName).Module + if module[-3:] == '.py' and not module.startswith('__'): + realName = '.'.join(('modules', module[:-3])) + self.modules[module[:-3]] = __import__(realName, fromlist=module[:-3]).Module @@ -82,7 +82,7 @@ for i, module in enumerate(self.openModules[prio]): if type(name) == str: - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: module.close() del self.openModules[prio][i] print 'Interface.closeModule: Close', name, 'at', prio, '-', i @@ -129,7 +129,7 @@ #Search within the given priorities for prio in prioList: for i, module in enumerate(self.openModules[prio]): - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: return True return False @@ -148,7 +148,7 @@ for prio in prioList: for i, module in enumerate(self.openModules[prio]): if type(name) == str: - if module.__module__ == 'modules/' + name: + if module.__module__ == 'modules.' + name: if len(self.openModules[prio])-1 != i: self.openModules[prio].append(self.openModules[prio].pop(i)) self.update(blit = True) @@ -270,7 +270,7 @@ self.lock.acquire() for prio in range(5): for module in self.openModules[prio]: - if name == '' or module.__module__ == 'modules/' + name: + if name == '' or module.__module__ == 'modules.' + name: module.call(*arg) self.forceUpdate() Added: trunk/VP/modules/__init__.py =================================================================== --- trunk/VP/modules/__init__.py (rev 0) +++ trunk/VP/modules/__init__.py 2009-05-01 15:27:26 UTC (rev 295) @@ -0,0 +1 @@ +# Dummy file, not a module. Do NOT remove this file! Modified: trunk/VP/modules/playground.py =================================================================== --- trunk/VP/modules/playground.py 2009-03-31 20:46:57 UTC (rev 294) +++ trunk/VP/modules/playground.py 2009-05-01 15:27:26 UTC (rev 295) @@ -25,10 +25,10 @@ #Loading all our objects-modules (kinda like interface.py) self.modObjects = {} - for object in os.listdir(getRealDir('modules','playground')): - if object[-3:] == '.py': - realName = os.path.join('modules', 'playground', object[:-3]) - self.modObjects[object[:-3]] = __import__(realName).Object + for object in os.listdir(getRealDir('modules','playgroundObj')): + if object[-3:] == '.py' and not object.startswith('__'): + realName = '.'.join(('modules', 'playgroundObj', object[:-3])) + self.modObjects[object[:-3]] = __import__(realName, fromlist=object[:-3]).Object self.surf = pygame.Surface((726, 402)) Property changes on: trunk/VP/modules/playgroundObj ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/VP/modules/playgroundObj/__init__.py =================================================================== --- trunk/VP/modules/playgroundObj/__init__.py (rev 0) +++ trunk/VP/modules/playgroundObj/__init__.py 2009-05-01 15:27:26 UTC (rev 295) @@ -0,0 +1 @@ +# Dummy file, not a playground-module. Do NOT remove this file! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |