Mercurial > hg
comparison mercurial/packagescan.py @ 2993:985594e891b8
Support foo@bar notation as demandload module spec.
author | Shun-ichi GOTO <shunichi.goto@gmail.com> |
---|---|
date | Tue, 22 Aug 2006 14:31:56 +0900 |
parents | 345bac2bc4ec |
children | 799811087044 |
comparison
equal
deleted
inserted
replaced
2967:eef469259745 | 2993:985594e891b8 |
---|---|
23 requiredmodules = {} | 23 requiredmodules = {} |
24 def demandload(scope, modules): | 24 def demandload(scope, modules): |
25 """ fake demandload function that collects the required modules | 25 """ fake demandload function that collects the required modules |
26 foo import foo | 26 foo import foo |
27 foo bar import foo, bar | 27 foo bar import foo, bar |
28 foo@bar import foo as bar | |
28 foo.bar import foo.bar | 29 foo.bar import foo.bar |
29 foo:bar from foo import bar | 30 foo:bar from foo import bar |
30 foo:bar,quux from foo import bar, quux | 31 foo:bar,quux from foo import bar, quux |
31 foo.bar:quux from foo.bar import quux""" | 32 foo.bar:quux from foo.bar import quux""" |
32 | 33 |
36 module, fromlist = m.split(':') | 37 module, fromlist = m.split(':') |
37 fromlist = fromlist.split(',') | 38 fromlist = fromlist.split(',') |
38 except: | 39 except: |
39 module = m | 40 module = m |
40 fromlist = [] | 41 fromlist = [] |
42 if '@' in module: | |
43 module, as_ = module.split('@') | |
41 mod = __import__(module, scope, scope, fromlist) | 44 mod = __import__(module, scope, scope, fromlist) |
42 if fromlist == []: | 45 if fromlist == []: |
43 # mod is only the top package, but we need all packages | 46 # mod is only the top package, but we need all packages |
44 comp = module.split('.') | 47 comp = module.split('.') |
45 i = 1 | 48 i = 1 |