view mercurial/demandload.py @ 386:494c8e3f47f3

Improvements for hg identify: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Improvements for hg identify: Don't add the modified flag if unknown files are found. Remove extra space if there was no tag found. Multiple tags for a single parent separated by '/'. Getting rid of sum() to aid porting to Python 2.2. manifest hash: f91224afcb239908ba3ef02299fcf2b0380ebd1a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCspWvW7P1GVgWeRoRAnqbAJwL1DIzOxOrdqpPj9vsYJeeiq+VrQCcCyli P+b/S0s2n628ku1IfrW3Elo= =lgRY -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 17 Jun 2005 10:19:43 +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