def resolve(self, uri, from_resource=None):
upath = Resource.normalize(uri)
uri_str, fragment = upath.rsplit('#', maxsplit=1)
if uri_str in self.resources:
return Resource._navigate_from(fragment, self.resources[uri_str])
start = from_resource.uri.normalize() if from_resource else '.'
apath = path.dirname(start)
uri = URI(path.join(apath, uri_str))
epackage = self.resources[uri.normalize()]
if isinstance(epackage, Resource):
epackage = epackage.contents[0]
return Resource._navigate_from(fragment, epackage)
评论列表
文章目录