From 03dd00bffe21f023839f6a5f5bdf7aceb9c83309 Mon Sep 17 00:00:00 2001 From: georgecao Date: Tue, 15 Dec 2020 15:43:26 +0800 Subject: [PATCH 1/4] Modify a test info. --- TEAM_INFO/legalids.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TEAM_INFO/legalids.yaml b/TEAM_INFO/legalids.yaml index fd79f6d..47504d2 100644 --- a/TEAM_INFO/legalids.yaml +++ b/TEAM_INFO/legalids.yaml @@ -1,4 +1,4 @@ legal_team_ids: - 123324214343 -- 999943645633 +- 888843645633 - 875453534224 -- Gitee From c8d62a131ee1bd30031d122ba642fbdff6e49b66 Mon Sep 17 00:00:00 2001 From: georgecao Date: Tue, 15 Dec 2020 19:28:10 +0800 Subject: [PATCH 2/4] Update README.md for TEAM_INFO --- TEAM_INFO/README.md | 61 ++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/TEAM_INFO/README.md b/TEAM_INFO/README.md index 1eb2fad..6872d0e 100644 --- a/TEAM_INFO/README.md +++ b/TEAM_INFO/README.md @@ -5,7 +5,7 @@

TEAMINFO 格式规范

背景

-

2020 openEuler 高校开发者大赛采用一个参赛团队一个代码仓库,分仓提交参赛代码的方式。依托码云(gitee)良好的代码托管服务,我们组委会为大家申请了一个专门为本次大赛服务的竞赛组织 openEuler2020, 并计划在该组织下为各个参赛团队新建代码仓库和添加参赛者权限。我们会根据各位参赛者在本仓库的teaminfo.yaml中提交的仓库信息和团队成员信息来建仓和加权限。所以希望各位参赛者能完整、清晰地提交团队、参赛者、仓库、导师等信息。
+

2020 openEuler 高校开发者大赛采用一个参赛团队一个代码仓库,分组提交参赛代码的方式。依托码云(gitee)良好的代码托管服务,我们组委会为大家申请了一个专门为本次大赛服务的竞赛组织 openEuler2020, 并计划在该组织下为各个参赛团队新建代码仓库和添加参赛者权限。我们会根据各位参赛者在本仓库的teaminfo.yaml中提交的仓库信息和团队成员信息来建仓和加权限。所以希望各位参赛者能完整、清晰地提交团队、参赛者、仓库、导师等信息。
具体的配置文件信息说明请见下文。

格式说明

大赛代码仓库的组织管理信息采用yaml格式文件记录承载,格式如下:

@@ -20,16 +20,16 @@ -verison -浮点数 -文件规范版本,由大赛组委会指定 - - community 字符串 组织名称,由大赛组委会指定 +verison +浮点数 +文件规范版本,由大赛组委会指定 + + giteeurl 字符串 在码云上的组织URL地址,由大赛组委会指定 @@ -72,35 +72,60 @@ 参赛队代码仓名称,必填 -type +repotype 枚举,public/private 参赛队的代码仓库类型,public为公开仓代码所有人可见,private为私有仓仅仓库成员和组织管理员可见;由于比赛性质,建议比赛阶段设置为private,比赛结束后改为public;必填 tutor -字符串数组 -出题导师gitee ID,可能一位或两位,必填 +清单 +一位或两位出题导师信息清单,一条记录为一位导师信息,必填 members +清单 +参赛队队员信息清单,一条记录为一位参赛队员信息,必填 + + +

其中tutor和members清单中一条记录的信息格式如下:

+ + + + + + + + + + + + + + + + + - +
字段类型说明
giteeid字符串数组该用户的gitee ID信息
email 字符串数组需要添加为仓库成员的参赛队员gitee ID;只有此处添加了gitee ID的仓库成员才有权限往仓库提交代码;由于代码仓限制,每个仓库仅能添加4位成员,其中一位或两位导师;如果团队成员数大于3可以通过其他参赛队员提交,也可以动态调整仓库成员名单获得仓库成员权限提交;必填该用户向gitee注册的邮箱地址信息

样例

-
version: 1.0
-community: openeuler2020
+
community: openeuler2020
+version: 1.0
 giteeurl: https://gitee.com/openeuler2020
 teams:
-- teamid: 0000
-  teamname: OSCHINA
+- teamid: 123324214343
+  teamname: "OSCHINA"
   description: "赛题77,团队编号:0000,团队名称:OSCHINA"
   repository: template
-  repotype: public
+  repotype: private
   tutor: 
-  - biglizi
+  - giteeid: biglizi
+    email: chenshuyu@oschina.cn
   members:
-  - leikeke
-  - georgecao
+  - giteeid: leikeke
+    email: leikeke2@huawei.com
+  - giteeid: georgecao
+    email: caozhi1214@qq.com
 
-- Gitee From ca604c0bc99a7df6ab3f73bc8ca186e5dc0efab7 Mon Sep 17 00:00:00 2001 From: "George.Cao" Date: Tue, 15 Dec 2020 23:49:21 +0800 Subject: [PATCH 3/4] add script/ci_valid_check.py. --- script/ci_valid_check.py | 283 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 script/ci_valid_check.py diff --git a/script/ci_valid_check.py b/script/ci_valid_check.py new file mode 100644 index 0000000..beac669 --- /dev/null +++ b/script/ci_valid_check.py @@ -0,0 +1,283 @@ + +''' +This is a bot for openEuler competition repository manage. +''' + +import argparse +import yaml +import os +import sys +import requests + +TEAMINFO = "TEAM_INFO/teaminfo.yaml" +LEGALIDS = "TEAM_INFO/legalids.yaml" +COMMUNITY = "openeuler2020" +ORG_API = "https://gitee.com/api/v5/orgs/" +USER_API = "https://gitee.com/api/v5/users/" +CLA_API = "https://clasign.osinfra.cn/api/v1/individual-signing/gitee/openeuler" + +def team_has_keyfield(team): + issue_found = 0 + if 'teamid' not in team.keys() or len(team['teamid']) == 0: + print("There is no team id.") + issue_found += 1 + return issue_found + if 'teamname' not in team.keys() or len(team['teamname']) == 0: + print("There is no team name.") + issue_found += 1 + return issue_found + if 'description' not in team.keys(): + print("There is no team description, we will add it.") + if 'repository' not in team.keys() or len(team['repository']) == 0: + print("There is no repository name.") + issue_found += 1 + return issue_found + if 'repotype' not in team.keys() or len(team['repotype']) == 0: + print("There is no repo type.") + issue_found += 1 + return issue_found + if 'tutor' not in team.keys() or len(team['tutor']) == 0: + print("There is no tutor here.") + issue_found += 1 + return issue_found + if 'members' not in team.keys() or len(team['members']) == 0: + print("There is no team member here.") + issue_found += 1 + return issue_found + return issue_found + + +def repo_member_valid_check(user, token): + ''' + check someone in repository is valid or not. + :param user: + :param token: + :return: + ''' + issue_found = 0 + ''' + check user gitee id valid + ''' + user_url = USER_API + user['giteeid'] + param = {'access_token': token} + response = requests.get(user_url, params=param) + if response.status_code != 200: + print( + "Get User {} information from gitee failed.".format( + user['giteeid'])) + issue_found += 1 + return + ''' + check user cla sign. + ''' + cla_url = CLA_API + param = {'email': user['email']} + response = requests.get(user_url, params=param) + if response.status_code != 200: + print("Get User{} cla info failed.".format(user['giteeid'])) + issue_found += 1 + return issue_found + if not response.data.signed: + print("User{} has not signed CLA.".format(user['giteeid'])) + issue_found += 1 + + return issue_found + + +def member_check(team, token): + ''' + check tutor information is valid or not. + :param tutorinfo: + :return: + ''' + issue_found = 0 + membersinfo = team['members'] + for member in membersinfo: + if 'giteeid' not in member.keys(): + continue + if 'email' not in member.keys(): + continue + issue_found += repo_member_valid_check(member, token) + + return issue_found + + +def tutor_check(team, token): + ''' + check tutor information is valid or not. + :param tutorinfo: + :return: + ''' + issue_found = 0 + tutorsinfo = team['tutor'] + for tutor in tutorsinfo: + issue_found += repo_member_valid_check(tutor, token) + + return issue_found + + +def teamid_valid_check(team, legalids): + ''' + :param team: team information + :param legalids: legal team ids + :return: + ''' + issue_found = 0 + if team['teamid'] not in legalids: + issue_found += 1 + return issue_found + + +def teamid_reused_check(teamids): + ''' + check id reused or not. + :param teamids: + :return: + ''' + issue_found = 0 + if len(teamids) != len(set(teamids)): + issue_found += 1 + return issue_found + +def orgrepo_reused_check(repos): + ''' + check repo name reused or not. + :param repos:repository name set + :return: + ''' + issue_found = 0 + if len(repos) != len(set(repos)): + issue_found += 1 + return issue_found + + +def validaty_check_teaminfo(teams, token, legalids): + ''' + check team info valid. + :param teaminfo: team information. + :param legalids: legal team ids list. + :return: pass check return 0, else return issue count. + ''' + issue_found = 0 + + team_ids = [] + org_repos = [] + for team in teams: + issue_found += team_has_keyfield(team) + issue_found += teamid_valid_check(team, legalids) + issue_found += tutor_check(team, token) + issue_found += member_check(team, token) + + if issue_found == 0: + team_ids.append(team['teamid']) + org_repos.append(team['repository']) + ''' + team id, name, repositories reused check + ''' + issue_found += teamid_reused_check(team_ids) + issue_found += orgrepo_reused_check(org_repos) + + return issue_found + + +def validaty_check_version(version): + ''' + :param version: configure file version, current version 1.0 + :return: version equal 1.0 return 0, else return 1 + ''' + issue_found = 0 + if version != 1.0: + print("Version {} is not OK.".format(version)) + issue_found = 1 + return issue_found + + +def validaty_check_community(community, token): + ''' + :param community: configure file community, current value: openeuler2020 + :return: community equal 'openeuler2020' return 0, else return 1 + ''' + issue_found = 0 + if community != 'openeuler2020': + print("Community info{} is not correct.".format(community)) + issue_found += 1 + + orgurl = ORG_API + community + param = {'access_token': token} + response = requests.get(orgurl, params=param) + if response.status_code != 200: + print("Get organization {} information failed.".format(community)) + issue_found += 1 + + return issue_found + + +def load_yaml(directory, yaml_file): + """ + Helper for load YAML database + """ + yaml_path = os.path.expanduser(os.path.join(directory, yaml_file)) + try: + result = yaml.load( + open( + yaml_path, + encoding="utf-8"), + Loader=yaml.Loader) + except FileNotFoundError: + print("Cannot Load %s." % (yaml_path)) + print("Could be wrong path") + sys.exit(1) + except yaml.scanner.ScannerError as error: + print("%s: Invalid YAML file" % (yaml_path)) + print("Detailed Error Information:") + print(error) + sys.exit(1) + return result + + +def main(): + ''' + This is a main function entry + ''' + par = argparse.ArgumentParser() + par.add_argument( + "managerepo", + type=str, + help="Local path of competition manage info repository.") + par.add_argument( + "cfgtoken", + type=str, + help="Config repo User token ID information.") + args = par.parse_args() + cfgtoken = args.cfgtoken + data = load_yaml(args.managerepo, TEAMINFO) + legal_ids = load_yaml(args.managerepo, LEGALIDS) + + version = data["version"] + community = data["community"] + url = data["giteeurl"] + teams = data["teams"] + + issue_total = 0 + + issue_total += validaty_check_version(version) + issue_total += validaty_check_community(community, cfgtoken) + issue_total += validaty_check_teaminfo(teams, + cfgtoken, + legal_ids['legal_team_ids']) + + if issue_total != 0: + sys.exit(issue_total) + + print( + "Token {},\nFileVersion:{},\nCommunity:{},\nUrl:{},\nTeam0:{},\n LegalIds:{}.".format( + cfgtoken, + version, + community, + url, + teams[0], + legal_ids['legal_team_ids'][0])) + + +if __name__ == '__main__': + main() -- Gitee From 327f7840a7a1f409c796138f442bbe6a866884ee Mon Sep 17 00:00:00 2001 From: georgecao Date: Tue, 15 Dec 2020 23:56:40 +0800 Subject: [PATCH 4/4] update ci-check file. --- script/ci_valid_check.py | 565 +++++++++++++++++++-------------------- 1 file changed, 282 insertions(+), 283 deletions(-) diff --git a/script/ci_valid_check.py b/script/ci_valid_check.py index beac669..0867703 100644 --- a/script/ci_valid_check.py +++ b/script/ci_valid_check.py @@ -1,283 +1,282 @@ - -''' -This is a bot for openEuler competition repository manage. -''' - -import argparse -import yaml -import os -import sys -import requests - -TEAMINFO = "TEAM_INFO/teaminfo.yaml" -LEGALIDS = "TEAM_INFO/legalids.yaml" -COMMUNITY = "openeuler2020" -ORG_API = "https://gitee.com/api/v5/orgs/" -USER_API = "https://gitee.com/api/v5/users/" -CLA_API = "https://clasign.osinfra.cn/api/v1/individual-signing/gitee/openeuler" - -def team_has_keyfield(team): - issue_found = 0 - if 'teamid' not in team.keys() or len(team['teamid']) == 0: - print("There is no team id.") - issue_found += 1 - return issue_found - if 'teamname' not in team.keys() or len(team['teamname']) == 0: - print("There is no team name.") - issue_found += 1 - return issue_found - if 'description' not in team.keys(): - print("There is no team description, we will add it.") - if 'repository' not in team.keys() or len(team['repository']) == 0: - print("There is no repository name.") - issue_found += 1 - return issue_found - if 'repotype' not in team.keys() or len(team['repotype']) == 0: - print("There is no repo type.") - issue_found += 1 - return issue_found - if 'tutor' not in team.keys() or len(team['tutor']) == 0: - print("There is no tutor here.") - issue_found += 1 - return issue_found - if 'members' not in team.keys() or len(team['members']) == 0: - print("There is no team member here.") - issue_found += 1 - return issue_found - return issue_found - - -def repo_member_valid_check(user, token): - ''' - check someone in repository is valid or not. - :param user: - :param token: - :return: - ''' - issue_found = 0 - ''' - check user gitee id valid - ''' - user_url = USER_API + user['giteeid'] - param = {'access_token': token} - response = requests.get(user_url, params=param) - if response.status_code != 200: - print( - "Get User {} information from gitee failed.".format( - user['giteeid'])) - issue_found += 1 - return - ''' - check user cla sign. - ''' - cla_url = CLA_API - param = {'email': user['email']} - response = requests.get(user_url, params=param) - if response.status_code != 200: - print("Get User{} cla info failed.".format(user['giteeid'])) - issue_found += 1 - return issue_found - if not response.data.signed: - print("User{} has not signed CLA.".format(user['giteeid'])) - issue_found += 1 - - return issue_found - - -def member_check(team, token): - ''' - check tutor information is valid or not. - :param tutorinfo: - :return: - ''' - issue_found = 0 - membersinfo = team['members'] - for member in membersinfo: - if 'giteeid' not in member.keys(): - continue - if 'email' not in member.keys(): - continue - issue_found += repo_member_valid_check(member, token) - - return issue_found - - -def tutor_check(team, token): - ''' - check tutor information is valid or not. - :param tutorinfo: - :return: - ''' - issue_found = 0 - tutorsinfo = team['tutor'] - for tutor in tutorsinfo: - issue_found += repo_member_valid_check(tutor, token) - - return issue_found - - -def teamid_valid_check(team, legalids): - ''' - :param team: team information - :param legalids: legal team ids - :return: - ''' - issue_found = 0 - if team['teamid'] not in legalids: - issue_found += 1 - return issue_found - - -def teamid_reused_check(teamids): - ''' - check id reused or not. - :param teamids: - :return: - ''' - issue_found = 0 - if len(teamids) != len(set(teamids)): - issue_found += 1 - return issue_found - -def orgrepo_reused_check(repos): - ''' - check repo name reused or not. - :param repos:repository name set - :return: - ''' - issue_found = 0 - if len(repos) != len(set(repos)): - issue_found += 1 - return issue_found - - -def validaty_check_teaminfo(teams, token, legalids): - ''' - check team info valid. - :param teaminfo: team information. - :param legalids: legal team ids list. - :return: pass check return 0, else return issue count. - ''' - issue_found = 0 - - team_ids = [] - org_repos = [] - for team in teams: - issue_found += team_has_keyfield(team) - issue_found += teamid_valid_check(team, legalids) - issue_found += tutor_check(team, token) - issue_found += member_check(team, token) - - if issue_found == 0: - team_ids.append(team['teamid']) - org_repos.append(team['repository']) - ''' - team id, name, repositories reused check - ''' - issue_found += teamid_reused_check(team_ids) - issue_found += orgrepo_reused_check(org_repos) - - return issue_found - - -def validaty_check_version(version): - ''' - :param version: configure file version, current version 1.0 - :return: version equal 1.0 return 0, else return 1 - ''' - issue_found = 0 - if version != 1.0: - print("Version {} is not OK.".format(version)) - issue_found = 1 - return issue_found - - -def validaty_check_community(community, token): - ''' - :param community: configure file community, current value: openeuler2020 - :return: community equal 'openeuler2020' return 0, else return 1 - ''' - issue_found = 0 - if community != 'openeuler2020': - print("Community info{} is not correct.".format(community)) - issue_found += 1 - - orgurl = ORG_API + community - param = {'access_token': token} - response = requests.get(orgurl, params=param) - if response.status_code != 200: - print("Get organization {} information failed.".format(community)) - issue_found += 1 - - return issue_found - - -def load_yaml(directory, yaml_file): - """ - Helper for load YAML database - """ - yaml_path = os.path.expanduser(os.path.join(directory, yaml_file)) - try: - result = yaml.load( - open( - yaml_path, - encoding="utf-8"), - Loader=yaml.Loader) - except FileNotFoundError: - print("Cannot Load %s." % (yaml_path)) - print("Could be wrong path") - sys.exit(1) - except yaml.scanner.ScannerError as error: - print("%s: Invalid YAML file" % (yaml_path)) - print("Detailed Error Information:") - print(error) - sys.exit(1) - return result - - -def main(): - ''' - This is a main function entry - ''' - par = argparse.ArgumentParser() - par.add_argument( - "managerepo", - type=str, - help="Local path of competition manage info repository.") - par.add_argument( - "cfgtoken", - type=str, - help="Config repo User token ID information.") - args = par.parse_args() - cfgtoken = args.cfgtoken - data = load_yaml(args.managerepo, TEAMINFO) - legal_ids = load_yaml(args.managerepo, LEGALIDS) - - version = data["version"] - community = data["community"] - url = data["giteeurl"] - teams = data["teams"] - - issue_total = 0 - - issue_total += validaty_check_version(version) - issue_total += validaty_check_community(community, cfgtoken) - issue_total += validaty_check_teaminfo(teams, - cfgtoken, - legal_ids['legal_team_ids']) - - if issue_total != 0: - sys.exit(issue_total) - - print( - "Token {},\nFileVersion:{},\nCommunity:{},\nUrl:{},\nTeam0:{},\n LegalIds:{}.".format( - cfgtoken, - version, - community, - url, - teams[0], - legal_ids['legal_team_ids'][0])) - - -if __name__ == '__main__': - main() + +''' +This is a bot for openEuler competition repository manage. +''' + +import argparse +import yaml +import os +import sys +import requests + +TEAMINFO = "TEAM_INFO/teaminfo.yaml" +LEGALIDS = "TEAM_INFO/legalids.yaml" +COMMUNITY = "openeuler2020" +ORG_API = "https://gitee.com/api/v5/orgs/" +USER_API = "https://gitee.com/api/v5/users/" +CLA_API = "https://clasign.osinfra.cn/api/v1/individual-signing/gitee/openeuler" + +def team_has_keyfield(team): + issue_found = 0 + if 'teamid' not in team.keys(): + print("There is no team id.") + issue_found += 1 + return issue_found + if 'teamname' not in team.keys() or len(team['teamname']) == 0: + print("There is no team name.") + issue_found += 1 + return issue_found + if 'description' not in team.keys(): + print("There is no team description, we will add it.") + if 'repository' not in team.keys() or len(team['repository']) == 0: + print("There is no repository name.") + issue_found += 1 + return issue_found + if 'repotype' not in team.keys() or len(team['repotype']) == 0: + print("There is no repo type.") + issue_found += 1 + return issue_found + if 'tutor' not in team.keys() or len(team['tutor']) == 0: + print("There is no tutor here.") + issue_found += 1 + return issue_found + if 'members' not in team.keys() or len(team['members']) == 0: + print("There is no team member here.") + issue_found += 1 + return issue_found + return issue_found + + +def repo_member_valid_check(user, token): + ''' + check someone in repository is valid or not. + :param user: + :param token: + :return: + ''' + issue_found = 0 + ''' + check user gitee id valid + ''' + user_url = USER_API + user['giteeid'] + param = {'access_token': token} + response = requests.get(user_url, params=param) + if response.status_code != 200: + print( + "Get User {} information from gitee failed.".format( + user['giteeid'])) + issue_found += 1 + return + ''' + check user cla sign. + ''' + cla_url = CLA_API + param = {'email': user['email']} + response = requests.get(user_url, params=param) + if response.status_code != 200: + print("Get User{} cla info failed.".format(user['giteeid'])) + issue_found += 1 + return issue_found +# if not response.data.signed: +# print("User{} has not signed CLA.".format(user['giteeid'])) +# issue_found += 1 + + return issue_found + + +def member_check(team, token): + ''' + check tutor information is valid or not. + :param tutorinfo: + :return: + ''' + issue_found = 0 + membersinfo = team['members'] + for member in membersinfo: + if 'giteeid' not in member.keys(): + continue + if 'email' not in member.keys(): + continue + issue_found += repo_member_valid_check(member, token) + + return issue_found + + +def tutor_check(team, token): + ''' + check tutor information is valid or not. + :param tutorinfo: + :return: + ''' + issue_found = 0 + tutorsinfo = team['tutor'] + for tutor in tutorsinfo: + if 'giteeid' not in tutor.keys(): + continue + if 'email' not in tutor.keys(): + continue + issue_found += repo_member_valid_check(tutor, token) + + return issue_found + + +def teamid_valid_check(team, legalids): + ''' + :param team: team information + :param legalids: legal team ids + :return: + ''' + issue_found = 0 + if team['teamid'] not in legalids: + print("Team id:{} is not in legal team id list.", team['teamid']) + issue_found += 1 + return issue_found + + +def teamid_reused_check(teamids): + ''' + check id reused or not. + :param teamids: + :return: + ''' + issue_found = 0 + if len(teamids) != len(set(teamids)): + issue_found += 1 + return issue_found + +def orgrepo_reused_check(repos): + ''' + check repo name reused or not. + :param repos:repository name set + :return: + ''' + issue_found = 0 + if len(repos) != len(set(repos)): + issue_found += 1 + return issue_found + + +def validaty_check_teaminfo(teams, token, legalids): + ''' + check team info valid. + :param teaminfo: team information. + :param legalids: legal team ids list. + :return: pass check return 0, else return issue count. + ''' + issue_found = 0 + + team_ids = [] + org_repos = [] + for team in teams: + issue_found += team_has_keyfield(team) + issue_found += teamid_valid_check(team, legalids) + issue_found += tutor_check(team, token) + issue_found += member_check(team, token) + + if issue_found == 0: + team_ids.append(team['teamid']) + org_repos.append(team['repository']) + ''' + team id, name, repositories reused check + ''' + issue_found += teamid_reused_check(team_ids) + issue_found += orgrepo_reused_check(org_repos) + + return issue_found + + +def validaty_check_version(version): + ''' + :param version: configure file version, current version 1.0 + :return: version equal 1.0 return 0, else return 1 + ''' + issue_found = 0 + if version != 1.0: + print("Version {} is not OK.".format(version)) + issue_found = 1 + return issue_found + + +def validaty_check_community(community, token): + ''' + :param community: configure file community, current value: openeuler2020 + :return: community equal 'openeuler2020' return 0, else return 1 + ''' + issue_found = 0 + if community != 'openeuler2020': + print("Community info{} is not correct.".format(community)) + issue_found += 1 + + orgurl = ORG_API + community + param = {'access_token': token} + response = requests.get(orgurl, params=param) + if response.status_code != 200: + print("Get organization {} information failed.".format(community)) + issue_found += 1 + + return issue_found + + +def load_yaml(directory, yaml_file): + """ + Helper for load YAML database + """ + yaml_path = os.path.expanduser(os.path.join(directory, yaml_file)) + try: + result = yaml.load( + open( + yaml_path, + encoding="utf-8"), + Loader=yaml.Loader) + except FileNotFoundError: + print("Cannot Load %s." % (yaml_path)) + print("Could be wrong path") + sys.exit(1) + except yaml.scanner.ScannerError as error: + print("%s: Invalid YAML file" % (yaml_path)) + print("Detailed Error Information:") + print(error) + sys.exit(1) + return result + + +def main(): + ''' + This is a main function entry + ''' + par = argparse.ArgumentParser() + par.add_argument( + "managerepo", + type=str, + help="Local path of competition manage info repository.") + par.add_argument( + "cfgtoken", + type=str, + help="Config repo User token ID information.") + args = par.parse_args() + cfgtoken = args.cfgtoken + data = load_yaml(args.managerepo, TEAMINFO) + legal_ids = load_yaml(args.managerepo, LEGALIDS) + + version = data["version"] + community = data["community"] + url = data["giteeurl"] + teams = data["teams"] + + print("FileVersion:{},\nCommunity:{},\nUrl:{},\nTeam0:{},\n LegalIds:{}.".format(version, + community, url, teams[0], legal_ids['legal_team_ids'][0])) + issue_total = 0 + + issue_total += validaty_check_version(version) + issue_total += validaty_check_community(community, cfgtoken) + issue_total += validaty_check_teaminfo(teams, + cfgtoken, + legal_ids['legal_team_ids']) + + if issue_total != 0: + sys.exit(issue_total) + + print("FINISH") + +if __name__ == '__main__': + main() -- Gitee