mercurial/demandload.py
author Johannes Stezenbach <js@linuxtv.org>
Mon, 06 Feb 2006 17:34:39 -0600
changeset 1702 e291d9a30bef
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
add --mbox output to patchbomb add option to save generated mails in an mbox file for later processing with formail, instead of sending them directly

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