view mercurial/demandload.py @ 603:bc5d058e65e9

[PATCH] Get "hg serve" to print the URL being served -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Get "hg serve" to print the URL being served From: Bryan O'Sullivan <bos@serpentine.com> If invoked with verbosity, print the URL at which we are serving. Useful if you bind to any port with "-p 0", and need to know what port the server is listening on. manifest hash: d317225606fbd2ec5819e1f266575b0485dfba79 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCyL9hywK+sNU5EO8RAjFQAJoDBRl5VoGIklxA1PdFGCt8Jb3iMQCeILeD XAwnnSCy/IQ/MDfYf6z7oWI= =FNVC -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sun, 03 Jul 2005 20:47:29 -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