mercurial/demandload.py
author mpm@selenic.com
Tue, 28 Jun 2005 10:42:02 -0800
changeset 511 9f67222186bd
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Disallow merging of unrelated projects -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Disallow merging of unrelated projects manifest hash: 40badbca64e1ccfd83fee8cd7bf5099f57b6f8bf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwZn6ywK+sNU5EO8RAmdeAJ9TAaGSe0nGMdL+Du3AGwm9x28IUgCgpfGG UunOBkobMVLGdHegnOvQkmQ= =VwVi -----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