mercurial/demandload.py
author mpm@selenic.com
Tue, 21 Jun 2005 21:07:08 -0800
changeset 430 5b22029b5aa2
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Fix up test-merge1 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fix up test-merge1 The third test was wrong and showed up after fixing the typo in compare code manifest hash: 306ab9936457ad90e7c7a226d6407ca586262650 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuPH8ywK+sNU5EO8RAql+AJsH/bxFMTMbUiaEoLNhXS6wNkzLAgCfQxDJ 3j5pZ3MzrtPD0y4wC3vIAA4= =VKEy -----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