From 48c6bbd18a8fb32660b1284bd253134efc009bc4 Mon Sep 17 00:00:00 2001 From: zengweifeng Date: Thu, 15 Oct 2020 16:58:07 +0800 Subject: [PATCH] support getting sourceforge package release info --- advisors/check_upstream.py | 28 ++++++++++++++++++++++++++++ advisors/oa_upgradable.py | 3 ++- advisors/yaml2url.py | 9 ++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/advisors/check_upstream.py b/advisors/check_upstream.py index 36d84767..d67e7e9c 100755 --- a/advisors/check_upstream.py +++ b/advisors/check_upstream.py @@ -453,7 +453,35 @@ def check_svn(info, clean_tag=True): if clean_tag: tags = clean_tags(tags, info) return tags +def check_sourceforge(info, clean_tag=True): + """ + Check python module version info via sourceforge api + """ + resp = load_last_query_result(info) + tags = [] + if resp == "": + headers = { + 'User-Agent' : 'Mozilla/5.0 (X11; Linux x86_64)' + } + url = yaml2url.yaml2url(info) + print("check_sourceforge, url = " + url) + resp = requests.get(url, headers=headers) + data = resp.text + data = data.splitlines() + filter_condition = "\"download_url\":" + for index in range(len(data)): + if filter_condition in data[index]: + str_list = data[index].split(',') + for str_index in range(len(str_list)): + if filter_condition in str_list[str_index]: + str_tmp = str_list[str_index].strip() + str_tmp = str_tmp.strip(filter_condition + " \"" + url) + str_tmp = str_tmp.strip('/download') + tags.append(str_tmp) + if clean_tag: + tags = clean_tags(tags, info) + return tags if __name__ == "__main__": pass diff --git a/advisors/oa_upgradable.py b/advisors/oa_upgradable.py index b8c6aa84..286fff80 100755 --- a/advisors/oa_upgradable.py +++ b/advisors/oa_upgradable.py @@ -74,7 +74,8 @@ def get_ver_tags(my_gitee, repo, clean_tag=True, cwd_path=None): "rubygem":check_upstream.check_rubygem, "gitee":check_upstream.check_gitee, "gnu-ftp":check_upstream.check_gnu_ftp, - "ftp":check_upstream.check_ftp + "ftp":check_upstream.check_ftp, + "sourceforge":check_upstream.check_sourceforge } check_method = switcher.get(vc_type, None) diff --git a/advisors/yaml2url.py b/advisors/yaml2url.py index aab97f5d..db522643 100755 --- a/advisors/yaml2url.py +++ b/advisors/yaml2url.py @@ -118,6 +118,12 @@ def __get_rubygem_url(pkg_info): url = urljoin("https://rubygems.org/api/v1/versions/", pkg_info["src_repo"] + ".json") return url +def __get_sourceforge_url(pkg_info): + """ + Get sourceforge url of package + """ + url = pkg_info["src_repo"] + return url def yaml2url(pkg_info): """ @@ -140,7 +146,8 @@ def yaml2url(pkg_info): "rubygem": __get_rubygem_url, "gitee": __get_gitee_url, "gnu-ftp": __get_gnu_ftp_url, - "ftp": __get_ftp_url + "ftp": __get_ftp_url, + "sourceforge":__get_sourceforge_url } get_url_method = switcher.get(vc_type, None) -- Gitee