Mercurial > hg > mercurial-crew-with-dirclash
changeset 2981:0171a5432621
Support the demandload syntax "@" in packagescan
author | Volker Kleinfeld <Volker.Kleinfeld@gmx.de> |
---|---|
date | Thu, 10 Aug 2006 16:59:58 +0200 |
parents | 49988d9f0758 |
children | 799811087044 |
files | mercurial/packagescan.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/packagescan.py +++ b/mercurial/packagescan.py @@ -26,6 +26,7 @@ def demandload(scope, modules): foo import foo foo bar import foo, bar foo.bar import foo.bar + foo@bar import foo as bar foo:bar from foo import bar foo:bar,quux from foo import bar, quux foo.bar:quux from foo.bar import quux""" @@ -38,6 +39,9 @@ def demandload(scope, modules): except: module = m fromlist = [] + as = None + if '@' in module: + module, as = module.split("@") mod = __import__(module, scope, scope, fromlist) if fromlist == []: # mod is only the top package, but we need all packages @@ -46,7 +50,9 @@ def demandload(scope, modules): mn = comp[0] while True: # mn and mod.__name__ might not be the same - scope[mn] = mod + if not as: + as = mn + scope[as] = mod requiredmodules[mod.__name__] = 1 if len(comp) == i: break mod = getattr(mod,comp[i])