diff --git a/bob/extension/test_utils.py b/bob/extension/test_utils.py index ae6bca1ab61750ddcb8d78c7ea0f8c52f397a121..23741083c50503865fdadb5167b3a4c9005d3bc3 100644 --- a/bob/extension/test_utils.py +++ b/bob/extension/test_utils.py @@ -111,15 +111,20 @@ package-z ] # test linkage to official documentation - server = "http://www.idiap.ch/software/bob/docs/bob/%s/master/" - os.environ["BOB_DOCUMENTATION_SERVER"] = server + server = ( + "http://www.idiap.ch/software/bob/docs/bob/%s/master/", + "http://www.idiap.ch/software/bob/docs/bob/%s/master/sphinx", + "http://www.idiap.ch/software/bob/docs/bob/%s/main/", + "http://www.idiap.ch/software/bob/docs/bob/%s/main/sphinx", + ) + os.environ["BOB_DOCUMENTATION_SERVER"] = "|".join(server) result = link_documentation(additional_packages, stringio(f)) expected = [ "https://docs.python.org/%d.%d/" % sys.version_info[:2], "https://matplotlib.org/stable/", "https://setuptools.readthedocs.io/en/latest/", - server % "bob.extension", - server % "gridtk", + server[0] % "bob.extension", + server[3] % "gridtk", ] result = [k[0] for k in result.values()] assert sorted(result) == sorted(expected) diff --git a/bob/extension/utils.py b/bob/extension/utils.py index e98a51656c3b33fa67c9c9a7e61998425c54ec3c..3761c2d3425e03308e9f3cb6a9cdd58464eadfc4 100644 --- a/bob/extension/utils.py +++ b/bob/extension/utils.py @@ -198,7 +198,14 @@ def link_documentation( if "BOB_DOCUMENTATION_SERVER" in os.environ: server = os.environ["BOB_DOCUMENTATION_SERVER"] else: - server = "http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/|http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/sphinx|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/sphinx" + server = ( + "http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/" + "|http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/sphinx" + "|http://www.idiap.ch/software/bob/docs/bob/%(name)s/main/" + "|http://www.idiap.ch/software/bob/docs/bob/%(name)s/main/sphinx" + "|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/" + "|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/sphinx" + ) # array support for BOB_DOCUMENTATION_SERVER # transforms "(file:///path/to/dir https://example.com/dir| http://bla )" @@ -226,7 +233,7 @@ def link_documentation( ) except pkg_resources.DistributionNotFound: version = "stable" # package is not a runtime dep, only referenced - url = s % {"name": package_name, "version": version} + url = s.format(name=package_name, version=version) try: # otherwise, urlopen will fail @@ -249,6 +256,7 @@ def link_documentation( # url request failed with a something else than 404 Error print("Requesting URL %s returned error: %s" % (url, exc)) # notice mapping is not updated here, as the URL does not exist + print(f"Nothing found at {url}.") except URLError as exc: print(