mercurial/demandload.py
author Josef "Jeff" Sipek <jeffpc@optonline.net>
Sun, 05 Feb 2006 20:52:55 -0500
changeset 1668 586b50294ea8
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
[hgweb] Added rename information to gitweb templates & misc cleanups Fixed up file log template's title Removed double entry for filelogentry in gitweb map file

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