view mercurial/demandload.py @ 479:7293cb91bf2a

Cleaned up command alias handling in help. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Cleaned up command alias handling in help. manifest hash: cfff5b739437073beddbc6e1f4c47ca958eeb1b2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCvqocW7P1GVgWeRoRAkM/AJ9iXHfhyAJH8kL167OiG95EJSsAKwCfWZFt 5S2AiXffxtPLIzxb/evzHZQ= =ppvs -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 26 Jun 2005 14:14:04 +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