diff --git a/advisors/oa_upgradable.py b/advisors/oa_upgradable.py old mode 100644 new mode 100755 index 781044377bbe187228550440c285d8163eb32abd..5447e0943df926b015ab853154f537c2653aa5a2 --- a/advisors/oa_upgradable.py +++ b/advisors/oa_upgradable.py @@ -2,16 +2,13 @@ """ This is a script to check upgradable information against upstream """ -from pyrpm.spec import Spec, replace_macros - -import yaml -import json -import datetime -import sys import os +import sys import argparse -import urllib.error +from pyrpm.spec import Spec, replace_macros + +import yaml import gitee import check_upstream @@ -22,7 +19,8 @@ def _get_rec_excpt(): """ Get except case of version recommend """ - y_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "helper/ver_rec_excpt.yaml")) + y_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), + "helper/ver_rec_excpt.yaml")) excpt = yaml.load(y_file, Loader=yaml.Loader) return excpt @@ -31,10 +29,10 @@ def _filter_except(excpts, sources): """ Filter except case in sources """ - for e in excpts: - sources = [s for s in sources if e not in s] + for exp in excpts: + sources = [s for s in sources if exp not in s] return sources - + def get_ver_tags(gt, repo, cwd_path=None): """ @@ -44,7 +42,8 @@ def get_ver_tags(gt, repo, cwd_path=None): try: repo_yaml = open(os.path.join(cwd_path, repo + ".yaml")).read() except FileNotFoundError: - print("WARNING: {pkg}.yaml can't be found in local path: {path}.".format(pkg=repo, path=cwd_path)) + print("WARNING: {pkg}.yaml can't be found in local path: {path}.".format(pkg=repo, + path=cwd_path)) repo_yaml = gt.get_yaml(repo) else: repo_yaml = gt.get_yaml(repo) @@ -84,18 +83,21 @@ def get_ver_tags(gt, repo, cwd_path=None): excpt_list = _get_rec_excpt() if repo in excpt_list: - tags = _filter_except(excpt_list[repo], tags) + tags = _filter_except(excpt_list[repo], tags) return tags -if __name__ == "__main__": +def main(): + """ + Main entrance of the functionality + """ parameters = argparse.ArgumentParser() parameters.add_argument("-p", "--push", action="store_true", - help="Push the version bump as an issue to src-openeuler repository") + help="Push the version bump as an issue to src-openeuler repository") parameters.add_argument("-d", "--default", type=str, default=os.getcwd(), - help="The fallback place to look for YAML information") + help="The fallback place to look for YAML information") parameters.add_argument("repo", type=str, - help="Repository to be checked for upstream version info") + help="Repository to be checked for upstream version info") args = parameters.parse_args() @@ -140,4 +142,10 @@ Please consider upgrading. Yours openEuler Advisor. If you think this is not proper issue, Please visit https://gitee.com/openeuler/openEuler-Advisor. -Issues and feedbacks are welcome.""".format(repo=args.repo, ver=ver_rec.latest_version, cur_ver=cur_version)) +Issues and feedbacks are welcome.""".format(repo=args.repo, + ver=ver_rec.latest_version, + cur_ver=cur_version)) + + +if __name__ == "__main__": + main()