mercurial/demandload.py
author mpm@selenic.com
Wed, 15 Jun 2005 17:18:06 -0800
changeset 367 73ea73ab3359
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Use errno.EPIPE rather than 32 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Use errno.EPIPE rather than 32 manifest hash: c9cb2fadf7ef4392b2f16b3f76ca2a39964b7ae0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsNNOywK+sNU5EO8RAudrAKCGKfgsHmSLdt5HYpUtX4S/QSFCQgCeKb7M Qld4CLe1M3aktU0tugb51Gs= =1LB7 -----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