mercurial/demandload.py
author Thomas Arendsen Hein <thomas@intevation.de>
Sun, 19 Jun 2005 21:04:32 +0100
changeset 427 36e644d28edf
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Make it possible to specify a version number in setup.py. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Make it possible to specify a version number in setup.py. manifest hash: 905feb305205801eb3833e5a84161fb57b83c86e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCtc/QW7P1GVgWeRoRAlCaAJ9G2GRf0wIEVEbYNoV4PjV4b024bQCfcUFf WVYQlTXqninDXyKas2yQYdo= =ofg/ -----END PGP SIGNATURE-----

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