view mercurial/demandload.py @ 700:d01b93efecd6

Removed extra spaces for default parameters according to PEP8. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Removed extra spaces for default parameters according to PEP8. manifest hash: 0f6bcc95adf406c8f6dafd92b7c7d3523b6dfe2c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC1oNhW7P1GVgWeRoRAn76AJ4m8rFUeeUDRC0qVEmjjmPClmAFsQCdE3rN Juv2dSoGteRm0DBXz7xnF4c= =PMki -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 14 Jul 2005 16:23:13 +0100
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