view mercurial/demandload.py @ 483:27f5569a5814

Updated TODO -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Updated TODO manifest hash: c73376bc97920d14c8e29311a76313afd71ed457 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCvtiZW7P1GVgWeRoRAsdeAKCazz6dq6fiuq37FGsRKbavfW+4xwCeKbmG N7HBvJ71yVTX45heHiSh8c8= =AgqS -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 26 Jun 2005 17:32:25 +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