view mercurial/demandload.py @ 532:2e9698a5c92c

clone: abort on pre-existing destination directory -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 clone: abort on pre-existing destination directory manifest hash: c1c205ea212ed73521cebe0524da364f40ebf387 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCxCIjywK+sNU5EO8RArteAKCM7oPK+htBvhz7n0Eo//A1BuGRQwCfY1xL 7denU7OqsKUf9UKKkhbWLB8= =rhfi -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 30 Jun 2005 08:47:31 -0800
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