mercurial/demandload.py
author Thomas Arendsen Hein <thomas@intevation.de>
Thu, 12 Jan 2006 21:02:38 +0100
changeset 1620 6c61646fee5e
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Adjusted all but one test output for the new behaviour of localrepo.changes()

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