view mercurial/demandload.py @ 366:21306bd3e0f5

hgweb: remove pointless manifest reads -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: remove pointless manifest reads pointed out by Goffredo Baroncelli manifest hash: 7aa5b93dc73755f02887702d0a01118d91b3b289 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsNK6ywK+sNU5EO8RAhJeAJ9ck6KYdupiuuyXXU5Mr8upx+D/NgCcDJmI y7ZVFQoiaYFoJy+GWQ2zFes= =RHPt -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 15 Jun 2005 17:15:38 -0800
parents 3db700146536
children f3abe0bdccdd
line wrap: on
line source

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