mercurial/demandload.py
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 03 Feb 2006 11:54:16 +0100
changeset 1693 74a5cef971aa
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
hgweb/templates: remove unused vars from map-raw annotateline contains html and it is unused filenodelink is unused but should be defined

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