mercurial/demandload.py
author mpm@selenic.com
Tue, 07 Jun 2005 00:03:38 -0800
changeset 268 1634a7ea6748
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
unknown command fixups -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 unknown command fixups from Andrew Thompson manifest hash: 3ed1956585a905a52d93491ea95096be23c9acf8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCpVTaywK+sNU5EO8RAkvLAJ0ff8/kVQc93jGy5t1uJ5R8m0M4OACfZ1Ba O7CldaLkwEzqybw/5iL6NAw= =WGtU -----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