mercurial/demandload.py
author Will <will@glozer.net>
Wed, 16 Nov 2005 20:53:16 +0100
changeset 1548 18f3224da392
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
fix bug in setup.py introduced in r1508. The 'console' argument is expected to be a list of strings, but was changed to just a string.

def demandload(scope, modules):
    class d:
        def __getattr__(self, name):
            mod = self.__dict__["mod"]
            scope = self.__dict__["scope"]
            scope[mod] = __import__(mod, scope, scope, [])
            return getattr(scope[mod], name)

    for m in modules.split():
        dl = d()
        dl.mod = m
        dl.scope = scope
        scope[m] = dl