From f0db5c9e2f2ebbafed87f6b14c8f7b13de6aefec Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 20 Feb 2003 07:04:55 +0000 Subject: [PATCH] re-worked detectors initialisation - woohoo, no more cross-importing! git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1532 57a73879-2fb5-44c3-a270-3262357dd7e2 --- .../templates/classic/detectors/__init__.py | 26 +++++++++---------- .../templates/minimal/detectors/__init__.py | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/roundup/templates/classic/detectors/__init__.py b/roundup/templates/classic/detectors/__init__.py index 8342052..12ef967 100644 --- a/roundup/templates/classic/detectors/__init__.py +++ b/roundup/templates/classic/detectors/__init__.py @@ -15,23 +15,23 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: __init__.py,v 1.6 2002-09-11 21:39:17 richard Exp $ +#$Id: __init__.py,v 1.7 2003-02-20 07:04:55 richard Exp $ + +import sys, os, imp def init(db): ''' execute the init functions of all the modules in this directory ''' - import os, sys this_dir = os.path.split(__file__)[0] - try: - sys.path.insert(0, this_dir) - for file in os.listdir(this_dir): - file, ext = os.path.splitext(file) - if file == '__init__': - continue - if ext == '.py': - module = __import__(file) - module.init(db) - finally: - del sys.path[0] + for file in os.listdir(this_dir): + path = os.path.join(this_dir, file) + name, ext = os.path.splitext(file) + if name == '__init__': + continue + if ext == '.py': + module = imp.load_module(name, open(path), file, + ('.py', 'r', imp.PY_SOURCE)) + print (name, open(path), file, module) + module.init(db) # vim: set filetype=python ts=4 sw=4 et si diff --git a/roundup/templates/minimal/detectors/__init__.py b/roundup/templates/minimal/detectors/__init__.py index 185c409..9ae5e06 100644 --- a/roundup/templates/minimal/detectors/__init__.py +++ b/roundup/templates/minimal/detectors/__init__.py @@ -15,23 +15,23 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: __init__.py,v 1.1 2002-09-26 04:15:26 richard Exp $ +#$Id: __init__.py,v 1.2 2003-02-20 07:04:55 richard Exp $ + +import sys, os, imp def init(db): ''' execute the init functions of all the modules in this directory ''' - import os, sys this_dir = os.path.split(__file__)[0] - try: - sys.path.insert(0, this_dir) - for file in os.listdir(this_dir): - file, ext = os.path.splitext(file) - if file == '__init__': - continue - if ext == '.py': - module = __import__(file) - module.init(db) - finally: - del sys.path[0] + for file in os.listdir(this_dir): + path = os.path.join(this_dir, file) + name, ext = os.path.splitext(file) + if name == '__init__': + continue + if ext == '.py': + module = imp.load_module(name, open(path), file, + ('.py', 'r', imp.PY_SOURCE)) + print (name, open(path), file, module) + module.init(db) # vim: set filetype=python ts=4 sw=4 et si -- 2.39.5