def list_modules_in_package_path(package_path, prefix):
modules = []
path_to_walk = [(package_path, prefix)]
while len(path_to_walk) > 0:
curr_path, curr_prefix = path_to_walk.pop()
for importer, name, ispkg in pkgutil.walk_packages(
path=[curr_path]
):
if ispkg:
path_to_walk.append(
(
'%s/%s/' % (curr_path, name),
'%s.%s' % (curr_prefix, name)
)
)
else:
modules.append((name, '%s.%s' % (curr_prefix, name)))
return modules
评论列表
文章目录