From 43c5c190cb6cf0d2558e97333a5c2f4a7ad92ede Mon Sep 17 00:00:00 2001 From: zengweifeng Date: Fri, 16 Oct 2020 15:33:31 +0800 Subject: [PATCH] support to obtain the software package release info whose upstream community addresss is sourceforge --- advisors/check_upstream.py | 31 +++++++++++++++++++++++++++++++ advisors/oa_upgradable.py | 3 ++- advisors/yaml2url.py | 11 ++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/advisors/check_upstream.py b/advisors/check_upstream.py index 36d84767..f3950f28 100755 --- a/advisors/check_upstream.py +++ b/advisors/check_upstream.py @@ -455,5 +455,36 @@ def check_svn(info, clean_tag=True): return tags +def check_sourceforge(info, clean_tag=True): + """ + Check python module version info via sourceforge url + """ + 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 + lines = data.splitlines() + filter_condition = "\"download_url\": \"" + url + for line in lines: + if filter_condition in line: + tag_infos = line.split(',') + for tag_info in tag_infos: + if filter_condition in tag_info: + tag = tag_info.strip() + tag = tag.lstrip(filter_condition) + tag = tag.strip("/download\"") + tags.append(tag) + 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..81276410 100755 --- a/advisors/yaml2url.py +++ b/advisors/yaml2url.py @@ -119,6 +119,14 @@ def __get_rubygem_url(pkg_info): return url +def __get_sourceforge_url(pkg_info): + """ + Get git repo url of package + """ + url = pkg_info["src_repo"] + return url + + def yaml2url(pkg_info): """ Get url from yaml @@ -140,7 +148,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