view mercurial/demandload.py @ 494:6020bde714e4

Fixed test for previous change of 'hg -v history'. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fixed test for previous change of 'hg -v history'. manifest hash: 5a7d918645596751577b95d0dfba28fd70274b48 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCwOjDW7P1GVgWeRoRAvL7AJwO27B6qhOZZC+16SPjIxJBKz3BSwCghmkB OMzLY0CjZSHixF5xs0ZU6Dw= =F04F -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 28 Jun 2005 07:05:55 +0100
parents 3db700146536
children f3abe0bdccdd
line wrap: on
line source

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