view mercurial/demandload.py @ 543:61ead26cb8f0

Updated TODO -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Updated TODO manifest hash: 007f50cbf11632362229853439d2610a1ad3f989 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCxF+7W7P1GVgWeRoRAg8MAJ9k3HXkpmHk3SRYw9FiqfHh8sEDFQCfc5il 2T+hyWgBwBTTHYpBeujq/20= =cRVv -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 30 Jun 2005 22:10:19 +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