mercurial/demandload.py
author mpm@selenic.com
Wed, 15 Jun 2005 19:48:04 -0800
changeset 370 c90385d82aec
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
revlog: add a children function -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 revlog: add a children function manifest hash: eda39cb99d0df5b3262d97a9e161a8acceb1da3d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsPZ0ywK+sNU5EO8RAiAcAJ9D+y8zQ/Gai7CpTkfTamPFxmvVRACcDRv9 5HkupYyrxslGnGJpELaF1is= =zf1d -----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