mercurial/demandload.py
author mpm@selenic.com
Wed, 08 Jun 2005 10:50:50 -0800
changeset 279 5edd24db6dc7
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
permissions merge: remove a debugging print -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 permissions merge: remove a debugging print manifest hash: 488144aeb1544ecc377ab41983e6cabd4a8b1f5f -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCpz4KywK+sNU5EO8RAi+YAKCBmiiDkhe2ygCv4LF21RS3/iH0VgCeLwd5 c/yhTklZ9lnLWXy5dmuPNZk= =UtDf -----END PGP SIGNATURE-----

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