view mercurial/demandload.py @ 266:4af7677de4a9

Fix argument processing for patch and rawcommit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fix argument processing for patch and rawcommit manifest hash: fc76fcd22ca69185bbec1855f72dda5b692e03f3 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCpVNMywK+sNU5EO8RAn2nAJ4gBbdn8K6xN55Igh6J2ZJEMgRGBACgr0Xb KkjbnOrNL5uQmBHx59C7HdY= =qsQi -----END PGP SIGNATURE-----
author mpm@selenic.com
date Mon, 06 Jun 2005 23:57:00 -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