diff --git a/advisors/check_upstream.py b/advisors/check_upstream.py index 36d8476761f0a8d1c7bb6374b2fe1541283639b7..f3950f28c7b402f35a5b1c65b0c196375b7d26bc 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 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..81276410c11f930342efe939ca36b0d521994e9e 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)