mercurial/demandload.py
author mpm@selenic.com
Wed, 15 Jun 2005 21:13:08 -0800
changeset 375 b29219389b00
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Show nice short hashes in hgweb -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Show nice short hashes in hgweb manifest hash: c73a8e32a823af7ea7440d1db2b0c022a4366bb5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsQpkywK+sNU5EO8RAmSIAJ40aYEFBi07drKuPLuofXNaUkEFtgCghC9g mG8mmhucbBe4hcZWL0AdG8I= =Khp7 -----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