File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
apeye >= 1.0.0
2
- cawdrey >= 0.4.2
3
2
domdf-python-tools >= 2.8.0
4
3
packaging >= 20.9
5
4
requests >= 2.24.0
Original file line number Diff line number Diff line change 33
33
# stdlib
34
34
import functools
35
35
import json
36
+ import re
36
37
from typing import Dict , Optional , Tuple , Union
37
38
38
39
# 3rd party
39
40
import requests
40
- from cawdrey . utils import search_dict
41
+ from apeye . requests_url import RequestsURL
41
42
from domdf_python_tools .compat import importlib_resources
42
43
from domdf_python_tools .utils import stderr_writer
43
44
from packaging .requirements import Requirement
55
56
56
57
__all__ = ["get_sphinx_doc_url" , "fallback_mapping" , "seed_intersphinx_mapping" ]
57
58
59
+ _DOCUMENTATION_RE = re .compile (r"^[dD]oc(s|umentation)" )
60
+
58
61
59
62
@cache
60
63
def get_sphinx_doc_url (pypi_name : str ) -> str :
@@ -88,12 +91,12 @@ def get_sphinx_doc_url(pypi_name: str) -> str:
88
91
:exc:`apeye.slumber_url.exceptions.HttpNotFoundError` if the project could not be found on PyPI.
89
92
"""
90
93
91
- docs_dict = search_dict ( get_project_links (pypi_name ), r"^[dD]oc(s|umentation)" )
92
-
93
- if docs_dict :
94
+ for key , value in get_project_links (pypi_name ). items ():
95
+ if not _DOCUMENTATION_RE . match ( key ):
96
+ continue
94
97
95
98
# Follow redirects to get actual URL
96
- r = requests .head (list ( docs_dict . values ())[ 0 ], allow_redirects = True , timeout = 10 )
99
+ r = RequestsURL ( value ) .head (allow_redirects = True , timeout = 10 )
97
100
if r .status_code != 200 : # pragma: no cover
98
101
raise ValueError (f"Documentation URL not found: HTTP Status { r .status_code } ." )
99
102
You can’t perform that action at this time.
0 commit comments