-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrparser
executable file
·61 lines (52 loc) · 1.66 KB
/
rparser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python3
import argparse
import urllib.request
import urllib.parse
import json
RESULTS_PER_PAGE = 100
def show_releases(sdk: str) -> None:
"""
Get sdk product, sdk version;
use Github API to retrieve release
info for given SDK.
"""
params = urllib.parse.urlencode({"per_page": RESULTS_PER_PAGE})
urls = {
"web": f"https://api.github.com/repos/onfido/onfido-sdk-ui/releases?{params}",
"android": f"https://api.github.com/repos/onfido/onfido-android-sdk/releases?{params}",
"ios": f"https://api.github.com/repos/onfido/onfido-ios-sdk/releases?{params}",
}
url = urls[sdk]
request = urllib.request.Request(
url=url, method="GET", headers={"accept": "application/vnd.github.v3+json"}
)
with urllib.request.urlopen(request) as response:
releases = json.loads(response.read().decode("utf-8"))
for res in releases:
name = res.get("name", "Not found")
body = res.get("body", "Not found")
print("-" * 20)
print(f"Release: {name}")
print(body)
def get_options() -> argparse.Namespace:
"""
Parse program arguments (from command line);
return 'Namespace' object.
"""
parser = argparse.ArgumentParser(
prog="release parser",
description="Parse release notes",
)
parser.add_argument(
"-sdk",
action="store",
help="Select SDK Product",
metavar="",
default="web",
choices=("web", "android", "ios"),
)
options = parser.parse_args()
return options
if __name__ == "__main__":
options = get_options()
show_releases(options.sdk)