diff --git a/Helper/package_helper.py b/Helper/package_helper.py index 5c9a354c6aeb100713e83d8a8b0b0ffb7a33659c..ed415266fc4ad51886bd6f36d1abe9848d2a3989 100644 --- a/Helper/package_helper.py +++ b/Helper/package_helper.py @@ -18,10 +18,9 @@ This is a wiki bot tool for assisting community governance # ******************************************************************************/ import urllib.request -import bs4 -from utils.Issue import Issue -from utils.PullRequest import PullRequest +from model.Issue import Issue +from model.PullRequest import PullRequest class PackageHelper(object): diff --git a/Helper/report_helper.py b/Helper/report_helper.py index 358ad8532d1500d4f0fc7f7daba696261e4a6443..9904ffbc98e41a9930f890b0b84d41e3dbe912f0 100644 --- a/Helper/report_helper.py +++ b/Helper/report_helper.py @@ -100,5 +100,7 @@ class ReportHelper(object): print("Total sig num: ", len(sig_list)) for sig in sig_list: print(sig.get_sig_name()) + for maintainer in sig.get_maintainers(): + print(maintainer.get_name()) print("===== Print Sig List Done =====") diff --git a/Helper/sig_helper.py b/Helper/sig_helper.py index 205b78e0b1796f40c32993d67e3fc4e752ef86b6..f342c36b5c1aa7d06f9e16747997e81e372ec758 100644 --- a/Helper/sig_helper.py +++ b/Helper/sig_helper.py @@ -20,16 +20,16 @@ This is a wiki bot tool for assisting community governance import urllib.request import re -from utils.Sig import Sig -from utils.Package import Package +from model.Sig import Sig +from model.Maintainer import Maintainer +from model.Developer import Developer from Helper.package_helper import PackageHelper -url_sigs = "https://gitee.com/openeuler/community/tree/master/sig" -sig_pattern = r"- name: (.*)" -openeuler_software_pattern = r'"/openeuler/community/tree/master/sig/(.*)"' -src_openeuler_software_pattern = r"- (src-openeuler/.*)" +URL_SIG = "https://gitee.com/openeuler/community/tree/master/sig/" +PATTERN_SIG = r'"/openeuler/community/tree/master/sig/(.*)"' +PATTERN_MAINTAINER = r"- (.*?) " BlockList = [ "openeuler/blog", @@ -43,37 +43,27 @@ class SigHelper(object): print("===== Start Init Sig Info... =====") tmp_sig = None - page = urllib.request.urlopen(url_sigs) + # 获取sig列表 + page = urllib.request.urlopen(URL_SIG) contents = page.read().decode('utf-8') - pattern = re.compile(openeuler_software_pattern) + pattern = re.compile(PATTERN_SIG) signames = pattern.findall(contents) for signame in signames[1:]: sig = Sig(signame) sig_list.append(sig) - # print(sig_list) - lines = contents.split("\n") - for line in lines: - result = re.search(openeuler_software_pattern, line) - if result: - # print("get one openeuler software: ", result.group(1)) - tmp_package = Package(result.group(1)) - if tmp_package.get_package_name() in BlockList: - # print(tmp_package.getSoftwareName(), " is blocked, skip and continue") - continue - if tmp_sig: - tmp_sig.add_software(tmp_package) - continue - result = re.search(src_openeuler_software_pattern, line) - if result: - # print("get one src-openeuler software: ", result.group(1)) - tmp_package = Package(result.group(1)) - if tmp_package.get_package_name() in BlockList: - # print(tmp_package.getSoftwareName(), " is blocked, skip and continue") - continue - if tmp_sig: - tmp_sig.add_software(tmp_package) - continue + # 获取每个sig的各种信息 + for sig in sig_list: + url_maintainer = URL_SIG + sig.get_sig_name() + "/OWNERS" + page = urllib.request.urlopen(url_maintainer) + contents = page.read().decode('utf-8') + pattern = re.compile(PATTERN_MAINTAINER) + maintainer_names = pattern.findall(contents) + print(sig.get_sig_name(), maintainer_names) + for maintainer_name in maintainer_names: + maintainer = Developer(maintainer_name) + sig.add_maintainer(maintainer) + print("===== Init Sig Info Done =====") @staticmethod diff --git a/model/Developer.py b/model/Developer.py new file mode 100644 index 0000000000000000000000000000000000000000..6c8381182a645f2f18658603e9dc49e6a41b308a --- /dev/null +++ b/model/Developer.py @@ -0,0 +1,48 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Sinever +# Create: 2022-02-27 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + + +class Developer(object): + + def __init__(self, name): + self.__name = name + self.__comments = [] + self.__created_issues = [] + self.__summited_prs = [] + + def add_comment(self, comment): + self.__comments.append(comment) + + def add_created_issue(self, created_issue): + self.__created_issues.append(created_issue) + + def add_summited_pr(self, summited_pr): + self.__summited_prs.append(summited_pr) + + def get_name(self): + return self.__name + + def get_comments(self): + return self.__comments + + def get_created_issues(self): + return self.__created_issues + + def get_summited_prs(self): + return self.__summited_prs diff --git a/model/Issue.py b/model/Issue.py new file mode 100644 index 0000000000000000000000000000000000000000..153bf58b424d30bdc6de7ba1a81dfe7404508fcb --- /dev/null +++ b/model/Issue.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Hubble_Zhu +# Create: 2021-01-12 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + + +class Issue(object): + + def __init__(self, title, url, status): + self.__title = title + self.__creator = None + self.__assigner = None + self.__description = None + self.__create_date = None + self.__url = url + self.__status = status + + def get_title(self): + return self.__title + + def get_url(self): + return self.__url + diff --git a/model/Maintainer.py b/model/Maintainer.py new file mode 100644 index 0000000000000000000000000000000000000000..10425ceffc324e67321d556254bd77288b910b0d --- /dev/null +++ b/model/Maintainer.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Sinever +# Create: 2022-02-27 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + +from model.Developer import Developer + + +class Maintainer(Developer): + + def __init__(self): + self.__received_prs = [] + + def add_received_pr(self, received_pr): + self.__received_prs.append(received_pr) + + def get_received_pr(self): + return self.__received_prs diff --git a/model/Package.py b/model/Package.py new file mode 100644 index 0000000000000000000000000000000000000000..1e130ac00453373d28869e78e87a8806a7087c20 --- /dev/null +++ b/model/Package.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Hubble_Zhu +# Create: 2021-01-12 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + + +class Package(object): + + def __init__(self, name): + self.__name = name + self.__issues = [] + self.__pull_requests = [] + + def add_issue(self, issue): + self.__issues.append(issue) + + def add_pr(self, pr): + self.__pull_requests.append(pr) + + def get_package_name(self): + return self.__name + + def get_url(self): + return "https://gitee.com/" + self.__name + + def get_issue_list(self): + return self.__issues + + def get_pr_list(self): + return self.__pull_requests diff --git a/model/PullRequest.py b/model/PullRequest.py new file mode 100644 index 0000000000000000000000000000000000000000..4c44b4672433be0ff73d2e839d66956dc92f9c00 --- /dev/null +++ b/model/PullRequest.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Hubble_Zhu +# Create: 2021-01-12 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + + +class PullRequest(object): + + def __init__(self, title, url): + self.__title = title + self.__creator = None + self.__create_date = None + self.__ci_status = None + self.__url = url + self.__status = None + + def get_title(self): + return self.__title + + def get_url(self): + return self.__url diff --git a/model/Sig.py b/model/Sig.py new file mode 100644 index 0000000000000000000000000000000000000000..958ca26215a1a1ecd795241b634d9fdac460594b --- /dev/null +++ b/model/Sig.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Hubble_Zhu +# Create: 2021-01-12 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ + + +class Sig(object): + + def __init__(self, sigName): + self.__sigName = sigName + self.__packages = [] + self.__maintainers = [] + + def add_software(self, software): + self.__packages.append(software) + + def add_maintainer(self, maintainer): + self.__maintainers.append(maintainer) + + def get_sig_name(self): + return self.__sigName + + def get_package_list(self): + return self.__packages + + def get_maintainers(self): + return self.__maintainers + + diff --git a/model/__init__.py b/model/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..6dc5c08e95c6577c970aaef3fb4270825fc371f7 --- /dev/null +++ b/model/__init__.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 +""" +This is a wiki bot tool for assisting community governance +""" +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Hubble_Zhu +# Create: 2021-01-12 +# Description: This is a wiki bot tool for assisting community governance +# ******************************************************************************/ diff --git a/openeuler-wiki-bot.py b/openeuler-wiki-bot.py index 6013795e7bf66286c2ab92855893df8291af6b27..bd54a8351fb5e7bb584eab5a0d49abb6c097442c 100755 --- a/openeuler-wiki-bot.py +++ b/openeuler-wiki-bot.py @@ -70,6 +70,7 @@ def process_report(command_args): if __name__ == '__main__': + print("Welcome to use openEuler-wiki-bot.") parser = init_parser() args = parser.parse_args() if args.list: @@ -78,3 +79,4 @@ if __name__ == '__main__': process_report(args) else: parser.print_help() + print("See you next time.")