def search_load_path(self, ctx, item):
"""This is called by :meth:`search_for_source` when a
:attr:`Environment.load_path` is set.
If you want to change how the load path is processed,
overwrite this method.
"""
if has_magic(item):
# We glob all paths.
result = []
for path in ctx.load_path:
result.extend(self.glob(path, item))
return result
else:
# Single file, stop when we find the first match, or error
# out otherwise. We still use glob() because then the load_path
# itself can contain globs. Neat!
for path in ctx.load_path:
result = self.glob(path, item)
if result:
return result
raise IOError("'%s' not found in load path: %s" % (
item, ctx.load_path))
评论列表
文章目录