File tree Expand file tree Collapse file tree 2 files changed +26
-26
lines changed
Expand file tree Collapse file tree 2 files changed +26
-26
lines changed Original file line number Diff line number Diff line change 1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- #$Id: __init__.py,v 1.6 2002-09-11 21:39:17 richard Exp $
18+ #$Id: __init__.py,v 1.7 2003-02-20 07:04:55 richard Exp $
19+
20+ import sys , os , imp
1921
2022def init (db ):
2123 ''' execute the init functions of all the modules in this directory
2224 '''
23- import os , sys
2425 this_dir = os .path .split (__file__ )[0 ]
25- try :
26- sys .path .insert (0 , this_dir )
27- for file in os .listdir (this_dir ):
28- file , ext = os .path .splitext (file )
29- if file == '__init__' :
30- continue
31- if ext == '.py' :
32- module = __import__ (file )
33- module .init (db )
34- finally :
35- del sys .path [0 ]
26+ for file in os .listdir (this_dir ):
27+ path = os .path .join (this_dir , file )
28+ name , ext = os .path .splitext (file )
29+ if name == '__init__' :
30+ continue
31+ if ext == '.py' :
32+ module = imp .load_module (name , open (path ), file ,
33+ ('.py' , 'r' , imp .PY_SOURCE ))
34+ print (name , open (path ), file , module )
35+ module .init (db )
3636
3737# vim: set filetype=python ts=4 sw=4 et si
Original file line number Diff line number Diff line change 1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- #$Id: __init__.py,v 1.1 2002-09-26 04:15:26 richard Exp $
18+ #$Id: __init__.py,v 1.2 2003-02-20 07:04:55 richard Exp $
19+
20+ import sys , os , imp
1921
2022def init (db ):
2123 ''' execute the init functions of all the modules in this directory
2224 '''
23- import os , sys
2425 this_dir = os .path .split (__file__ )[0 ]
25- try :
26- sys .path .insert (0 , this_dir )
27- for file in os .listdir (this_dir ):
28- file , ext = os .path .splitext (file )
29- if file == '__init__' :
30- continue
31- if ext == '.py' :
32- module = __import__ (file )
33- module .init (db )
34- finally :
35- del sys .path [0 ]
26+ for file in os .listdir (this_dir ):
27+ path = os .path .join (this_dir , file )
28+ name , ext = os .path .splitext (file )
29+ if name == '__init__' :
30+ continue
31+ if ext == '.py' :
32+ module = imp .load_module (name , open (path ), file ,
33+ ('.py' , 'r' , imp .PY_SOURCE ))
34+ print (name , open (path ), file , module )
35+ module .init (db )
3636
3737# vim: set filetype=python ts=4 sw=4 et si
You can’t perform that action at this time.
0 commit comments