mercurial/demandload.py
author mpm@selenic.com
Wed, 15 Jun 2005 00:09:19 -0800
changeset 344 db419f14df4b
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Fix yet another resolve corner case -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fix yet another resolve corner case manifest hash: a194321b5cd718a3c31f327c5145a4ebd8dd4ef4 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCr+IvywK+sNU5EO8RAt49AJwLBBq7AZfo1WqcwZvzSVENvJGLmgCePumQ 0/9RwjL/PorsvFJi+CiFYyY= =S6HA -----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