mercurial/demandload.py
author Thomas Arendsen Hein <thomas@intevation.de>
Thu, 16 Jun 2005 05:44:05 +0100
changeset 376 fadc9e126369
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
hgweb: fix deleted file in filediff key error -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: fix deleted file in filediff key error manifest hash: f751d213d2d2d49b3631dbe72699554e58ae590a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCsQOVW7P1GVgWeRoRAvRAAJ9cLxO+QLg6gEnn/0XPZJP1G/8/KQCfdygL b+awDXRJmE0onoNzvzzIcBg= =jDV4 -----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