Message3449

Author wesleys
Recipients wesleys
Date 2008-08-26.10:01:12
SpamBayes Score 6.03105e-07
Marked as misclassified No
Message-id <1219744873.43.0.913940733736.issue1111@psf.upfronthosting.co.za>
In-reply-to
Content
Code:

def load_modules(dir, module_prefix = None):
    files = os.listdir(dir)
    files.sort()
    for filename in files:
        if not filename.endswith('.py') or not filename[0:1].isupper():
            continue

        file = filename[:-3]
        if module_prefix == None:
            mod = __import__(file, fromlist=filename)
        else:
            mod = __import__('%s.%s' % (module_prefix, file),
fromlist=filename)

        c = getattr(mod, file)
        o = c()
        info(o) // prints information about the module/class

path = "/home/wesleys/sbox/blpython/src/lib/OSS/bladelogic"
load_modules(path, "OSS.bladelogic")

Running this code in python (2.5.1) works as expected, with jython it
fails.. 

2.2.1:
Traceback (innermost last):
  File "test_logic.py", line 48, in ?
  File "test_logic.py", line 38, in load_modules
TypeError: __import__() takes no keyword arguments

2.5a1:
Traceback (most recent call last):
  File "test_logic.py", line 48, in <module>
    load_modules(path, "OSS.bladelogic")
  File "test_logic.py", line 38, in load_modules
    mod = __import__('%s.%s' % (module_prefix, file), fromlist=filename)
TypeError: __import__() takes no keyword arguments
History
Date User Action Args
2008-08-26 10:01:13wesleyssetrecipients: + wesleys
2008-08-26 10:01:13wesleyssetmessageid: <1219744873.43.0.913940733736.issue1111@psf.upfronthosting.co.za>
2008-08-26 10:01:13wesleyslinkissue1111 messages
2008-08-26 10:01:12wesleyscreate