diff --git a/advisors/check_upstream.py b/advisors/check_upstream.py index 36d8476761f0a8d1c7bb6374b2fe1541283639b7..d67e7e9c63b9fcbc2c3af68e391e05ad0681601b 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 b8c6aa847e73441cabcf25d338848097f1c2a46a..286fff80a4740a7770aded087f56ad132ade0147 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 aab97f5d333a6959982da852d0f9c81a79b4dc95..db522643825b8bdc04642331120c283a94207c75 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)