def index(tagname):
"""Return the name of the submodule that tagname is defined in,
as well as a list of modules and keys in which this tagname is used."""
mods = glob.glob1(__path__[0], '*.py')
keys = []
usedin = {}
for m in mods:
if m[:2] == '__':
continue
modname = __name__ + '.' + m[:-3]
path = string.split(modname, '.')
module = __import__(modname)
# find the deepest submodule
for modname in path[1:]:
module = getattr(module, modname)
if hasattr(module, 'content'):
c = module.content
for k in c.keys():
if k == tagname:
keys.append(m)
for item in c[k]:
if string.find(item, tagname) != -1:
usedin[(m, k)] = 1
return keys, usedin.keys()
评论列表
文章目录