"""
site customization module for mm director: imported in projector-mode only
"""

def re_mod(curdir, test=None):
    import sys, os
    sm = sys.modules
    lk = sm.keys()
    builtins = sys.builtin_module_names
    for i in lk:
        if i not in builtins:
            ex_mod(sm[i].__name__, curdir=curdir, test=test)

def ex_mod(module, curdir=['o:/pytest/test_py/lib'], test=None):
    """ exchanging loaded modules with modules from curdir """
    import imp, os
    try:
        x = imp.find_module(module, curdir)
        try:
            foo = imp.load_module(module, x[0], x[1], x[2])
            x[0].close()
            if test: print "reloaded module from", x[1]
        except:
            if test: print "no reload for module", x[1]
            x[0].close()
            pass
    except:
        if test: print "No reload-file for module", module
        pass
    
import sys, os
curdir = os.getcwd()
#curdir = os.path.normpath('o:/pytest/test_py')
newpaths = [".", "lib", "DLLs", "site"]
tmp = []
for i in newpaths:
    tmp.append(os.path.join(curdir, i))
newpaths = tmp
del tmp
curdir = newpaths
re_mod(curdir, test=1)
del curdir
sys.path = []
for i in newpaths:
    sys.path.append(i)
del newpaths

def _test():
    import sys
    print "sys.path:"
    print sys.path
    print "sys.modules:"
    import pprint
    pprint.pprint( sys.modules)

if __name__ == '__main__':
 
    _test()
    


Date: Nov 17, 2000, jbekesi@meta-ware.at