Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit cfa55af

Browse files
committed
ci: rm support for py38
feat: change usage of register proxy
1 parent ab62ad4 commit cfa55af

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.8, 3.9]
14+
python-version: [3.9]
1515

1616
steps:
1717
- uses: actions/checkout@v2

src/updater/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '0.2.0'
1+
VERSION = '0.2.1'

src/updater/github.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,32 @@ class Repo:
1616
repo: str
1717

1818

19-
def register_proxy(proxy: dict, auth: dict = None):
19+
def register_proxy(proxy: str, auth: dict = None):
20+
"""Build up a https proxy dict of `request` format
21+
22+
Args:
23+
proxy (str): proxy url, socks5 supoorted
24+
auth (dict, optional): auth dict. Needs `username` and `password` field. Defaults to None.
25+
26+
Returns:
27+
dict: `{'https': proxy_with_auth}`
28+
"""
2029
global PROXY
2130
if auth is None:
22-
PROXY = proxy.copy()
23-
return proxy
31+
PROXY = {'https': proxy}
32+
return PROXY.copy()
2433

2534
assert 'username' in auth
2635
assert 'password' in auth
2736
from urllib.parse import urlsplit
28-
PROXY = {}
2937

30-
for k in proxy:
31-
p = urlsplit(proxy[k])
32-
assert p.hostname
33-
url = f"{p.scheme}://{auth['username']}:{auth['password']}@{p.hostname}"
34-
if p.port: url += f":{p.port}"
35-
PROXY[k] = url
38+
p = urlsplit(proxy)
39+
assert p.hostname
40+
url = f"{p.scheme}://{auth['username']}:{auth['password']}@{p.hostname}"
41+
if p.port: url += f":{p.port}"
42+
PROXY = {'https': url}
3643

37-
return PROXY
44+
return PROXY.copy()
3845

3946

4047
class GhRelease(Release):

0 commit comments

Comments
 (0)