def search(self, description): if description.help_ref: ref = description.help_ref else: raise KeyError() url = QUrl(self.baseurl).resolved(QUrl(ref)) if url.isLocalFile(): path = url.toLocalFile() fragment = url.fragment() if os.path.isfile(path): return url elif os.path.isfile("{}.html".format(path)): url = QUrl.fromLocalFile("{}.html".format(path)) url.setFragment(fragment) return url elif os.path.isdir(path) and \ os.path.isfile(os.path.join(path, "index.html")): url = QUrl.fromLocalFile(os.path.join(path, "index.html")) url.setFragment(fragment) return url else: raise KeyError() else: if url.scheme() in ["http", "https"]: path = url.path() if not (path.endswith(".html") or path.endswith("/")): url.setPath(path + ".html") return url