view mercurial/demandload.py @ 388:398737777644

Fixed tests for displaying tags in hg history and hg parents. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fixed tests for displaying tags in hg history and hg parents. manifest hash: 1ff138f68590e11a20e1f375c0c7293bdfb9f1fb -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCsp/XW7P1GVgWeRoRAtS1AJ90tbAlt89jZr//nYMEgoVv2UL6GwCgih7L yFwVR4cWpSGyrl0zvYM3AiU= =6OjG -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 17 Jun 2005 11:03:03 +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