Skip to content

Commit 229b4c5

Browse files
authored
Merge pull request #22 from neatc0der/release/v2.1.1
Release/v2.1.1
2 parents 85950e7 + 128daa8 commit 229b4c5

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

changelog/v2.1.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# v2.1.1
2+
3+
* Fixes [proxy support](https://github.com/neatc0der/mkdocs-markmap/issues/20)
4+
* Replaces usage of `urllib3` with `requests`

mkdocs_markmap/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PACKAGE_NAME = 'mkdocs_markmap'
22
PROJECT_NAME = PACKAGE_NAME.replace('_', '-')
3-
PROJECT_VERSION = '2.1.0'
3+
PROJECT_VERSION = '2.1.1'
44

55
OWNER = 'neatc0der'
66
REPOSITORY_NAME = f'{OWNER}/{PROJECT_NAME}'

mkdocs_markmap/utils.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from pathlib import Path
44

55
from urllib.parse import unquote
6-
from urllib3 import PoolManager
7-
from urllib3.response import HTTPResponse
8-
from urllib3.util.retry import Retry
9-
from urllib3.util.url import Url, parse_url
6+
from requests.adapters import HTTPAdapter
7+
from requests import Response
8+
from requests.packages.urllib3.util.retry import Retry
9+
from requests.packages.urllib3.util.url import Url, parse_url
10+
from requests.sessions import Session
1011

1112

1213
log = logging.getLogger('mkdocs.markmap')
@@ -19,12 +20,18 @@ def download(base_path: Path, url: str, flat: bool = False, force_reload: bool =
1920
file_path: Path = base_path / sub_path
2021

2122
file_path.parent.mkdir(parents=True, exist_ok=True)
22-
retries = Retry(connect=5, read=2, redirect=5)
23-
http = PoolManager(retries=retries)
2423
if force_reload or not file_path.exists():
25-
response: HTTPResponse = http.request('GET', url)
24+
retries: Retry = Retry(connect=5, read=2, redirect=5)
25+
adapter: HTTPAdapter = HTTPAdapter(max_retries=retries)
26+
http: Session = Session()
27+
http.mount("https://", adapter)
28+
http.mount("http://", adapter)
29+
30+
response: Response = http.get(url, allow_redirects=True, timeout=3.0)
2631
with open(file_path, 'wb') as fp:
27-
fp.write(response.data)
32+
for chunk in response.iter_content(chunk_size=1024):
33+
if chunk:
34+
fp.write(chunk)
2835

2936
log.info(f'script downloaded: {url}')
3037

requirements/prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mkdocs>=1.1,<2
22
attrs==20.3.0
33
beautifulsoup4>=4.6.3
4-
urllib3==1.26.4
4+
requests==2.25.1

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@task
2020
def verify(c, tag=TARGET_TAG):
21-
print('verify integrity: {tag}')
21+
print(f'verify integrity: {tag}')
2222

2323
handler: ReleaseHandler = ReleaseHandler(tag)
2424
handler.verify()

0 commit comments

Comments
 (0)