From 310f540b52105dc518febbac60bcd387e33e56bf Mon Sep 17 00:00:00 2001 From: jakimowb Date: Mon, 4 Sep 2023 00:24:59 +0200 Subject: [PATCH 1/6] flake8 Signed-off-by: jakimowb --- enmapbox/coreapps/metadataeditorapp/metadatakeys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enmapbox/coreapps/metadataeditorapp/metadatakeys.py b/enmapbox/coreapps/metadataeditorapp/metadatakeys.py index c7859d3a..ae4529d2 100644 --- a/enmapbox/coreapps/metadataeditorapp/metadatakeys.py +++ b/enmapbox/coreapps/metadataeditorapp/metadatakeys.py @@ -418,7 +418,7 @@ def initListLength(self, obj, value): def setValue(self, value): def convertOrFail(value): - if type(value) != self.mType: + if type(value) is not self.mType: try: value = self.mType(value) except Exception as ex: From 4ce1901f1fce5895afdb32df7137b384d518236b Mon Sep 17 00:00:00 2001 From: jakimowb Date: Mon, 4 Sep 2023 00:49:59 +0200 Subject: [PATCH 2/6] closes #258 Signed-off-by: jakimowb --- scripts/create_report.py | 69 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/scripts/create_report.py b/scripts/create_report.py index da606aa2..ec518f6d 100644 --- a/scripts/create_report.py +++ b/scripts/create_report.py @@ -3,6 +3,7 @@ """ import argparse import csv +import requests import datetime import inspect import json @@ -20,7 +21,7 @@ from enmapbox.algorithmprovider import EnMAPBoxProcessingProvider from enmapbox.gui.applications import ApplicationWrapper, EnMAPBoxApplication from enmapbox.gui.enmapboxgui import EnMAPBox -from enmapbox.testing import start_app, stop_app +from enmapbox.testing import start_app from qgis.PyQt.QtWidgets import QMenu from qgis.core import QgsProcessing, QgsProcessingParameterRasterLayer, QgsProcessingParameterRasterDestination, \ QgsProcessingOutputVectorLayer, QgsProcessingParameterFeatureSink, QgsProcessingParameterFeatureSource, \ @@ -94,8 +95,66 @@ def report_github_issues() -> pd.DataFrame: is:issue created:2022-07-01..2022-12-31 is:issue closed:2022-07-01..2022-12-31 """ + # Your GitHub personal access token + assert 'GITHUB_TOKEN' in os.environ, 'GITHUB_TOKEN is not set. ' \ + 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' + token = os.environ['GITHUB_TOKEN'] + + # GitHub repository owner and name + owner = 'EnMAP-Box' + repo = 'enmap-box' + + # Define the date range + start_date = datetime.datetime.strptime('2023-01-01', '%Y-%m-%d') + end_date = datetime.datetime.strptime('2023-06-30', '%Y-%m-%d') + + # Create a session and set the authorization header + session = requests.Session() + session.headers.update({'Authorization': f'token {token}'}) + + # Get the list of issues from the GitHub API + issues_url = f'https://api.github.com/repos/{owner}/{repo}/issues' + params = { + 'state': 'all', # 'all' includes open and closed issues + 'per_page': 100, # Adjust as needed + } + all_issues = [] + + while True: + response = session.get(issues_url, params=params) + + response.raise_for_status() + all_issues.extend(response.json()) + + # Check if there are more pages of issues + link_header = response.headers.get('Link', '') + if 'rel="next"' not in link_header: + break + + rx = re.compile(r'<(.[^>]+)>; *rel="next"') + + # Extract the URL for the next page + link = [l.strip() for l in link_header.split(',') if 'rel="next"' in l] + if len(link) > 0: + link = link[0] + issues_url = rx.match(link).group(1) + else: + response.close() + break + + pull_requests = [i for i in all_issues if 'pull_request' in i] + issues = [i for i in all_issues if 'pull_request' not in i] + + # Filter issues within the date range + issues_created = [i for i in issues if + start_date <= datetime.datetime.strptime(i['created_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] + + issues_closed = [i for i in issues if i['closed_at'] and + start_date <= datetime.datetime.strptime(i['closed_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] - s = "" + print(f'Issues {start_date} to {end_date}') + print(f'Created: {len(issues_created)}') + print(f'Closed: {len(issues_closed)}') return None @@ -300,6 +359,10 @@ def byKey(ISSUES: list, key: str) -> dict: class TestCases(unittest.TestCase): + def test_github_2(self): + + report_github_issues() + def test_github_issue(self): path_json = pathlib.Path(DIR_REPO_TMP) / 'issues.json' @@ -364,5 +427,3 @@ def test_github_issue(self): dfPAs = report_processingalgorithms() dfPAs.to_excel(writer, sheet_name='PAs') - - stop_app() From 441328189d2fa50401503caed2d6e21fd7957828 Mon Sep 17 00:00:00 2001 From: jakimowb Date: Mon, 4 Sep 2023 00:54:58 +0200 Subject: [PATCH 3/6] flake8 Signed-off-by: jakimowb --- scripts/create_report.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/create_report.py b/scripts/create_report.py index ec518f6d..1932f792 100644 --- a/scripts/create_report.py +++ b/scripts/create_report.py @@ -97,7 +97,7 @@ def report_github_issues() -> pd.DataFrame: """ # Your GitHub personal access token assert 'GITHUB_TOKEN' in os.environ, 'GITHUB_TOKEN is not set. ' \ - 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' + 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' token = os.environ['GITHUB_TOKEN'] # GitHub repository owner and name @@ -149,8 +149,8 @@ def report_github_issues() -> pd.DataFrame: issues_created = [i for i in issues if start_date <= datetime.datetime.strptime(i['created_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] - issues_closed = [i for i in issues if i['closed_at'] and - start_date <= datetime.datetime.strptime(i['closed_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] + issues_closed = [i for i in issues if + i['closed_at'] and start_date <= datetime.datetime.strptime(i['closed_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] print(f'Issues {start_date} to {end_date}') print(f'Created: {len(issues_created)}') From b9bdd61c2b85d03bd0beb28a35a0a0d60a0cc508 Mon Sep 17 00:00:00 2001 From: "Benjamin Jakimow benjamin.jakimow@geo.hu-berlin.de" Date: Tue, 5 Sep 2023 15:51:29 +0200 Subject: [PATCH 4/6] save results to local file Signed-off-by: Benjamin Jakimow benjamin.jakimow@geo.hu-berlin.de --- scripts/create_report.py | 168 +++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 85 deletions(-) diff --git a/scripts/create_report.py b/scripts/create_report.py index 1932f792..55971f99 100644 --- a/scripts/create_report.py +++ b/scripts/create_report.py @@ -89,72 +89,108 @@ def report_downloads() -> pd.DataFrame: return df +def toDate(text, format: str = '%Y-%m-%dT%H:%M:%SZ') -> datetime.datetime: + return datetime.datetime.strptime(text, format) + + def report_github_issues() -> pd.DataFrame: """ is:issue created:2022-07-01..2022-12-31 is:issue closed:2022-07-01..2022-12-31 """ - # Your GitHub personal access token - assert 'GITHUB_TOKEN' in os.environ, 'GITHUB_TOKEN is not set. ' \ - 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' - token = os.environ['GITHUB_TOKEN'] # GitHub repository owner and name owner = 'EnMAP-Box' repo = 'enmap-box' # Define the date range - start_date = datetime.datetime.strptime('2023-01-01', '%Y-%m-%d') - end_date = datetime.datetime.strptime('2023-06-30', '%Y-%m-%d') - - # Create a session and set the authorization header - session = requests.Session() - session.headers.update({'Authorization': f'token {token}'}) - - # Get the list of issues from the GitHub API - issues_url = f'https://api.github.com/repos/{owner}/{repo}/issues' - params = { - 'state': 'all', # 'all' includes open and closed issues - 'per_page': 100, # Adjust as needed - } - all_issues = [] - - while True: - response = session.get(issues_url, params=params) - - response.raise_for_status() - all_issues.extend(response.json()) - - # Check if there are more pages of issues - link_header = response.headers.get('Link', '') - if 'rel="next"' not in link_header: - break - - rx = re.compile(r'<(.[^>]+)>; *rel="next"') - - # Extract the URL for the next page - link = [l.strip() for l in link_header.split(',') if 'rel="next"' in l] - if len(link) > 0: - link = link[0] - issues_url = rx.match(link).group(1) - else: - response.close() - break + start_date = toDate('2023-01-01', '%Y-%m-%d') + end_date = toDate('2023-06-30', '%Y-%m-%d') + + today = datetime.datetime.now().isoformat().split('T')[0] + + PATH_GH_JSON = pathlib.Path(__file__).parents[1] / 'tmp' / f'githubissues.{today}.json' + + if not PATH_GH_JSON.is_file(): + os.makedirs(PATH_GH_JSON.parent, exist_ok=True) + # Your GitHub personal access token + assert 'GITHUB_TOKEN' in os.environ, 'GITHUB_TOKEN is not set. ' \ + 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' + token = os.environ['GITHUB_TOKEN'] + + + + # Create a session and set the authorization header + session = requests.Session() + session.headers.update({'Authorization': f'token {token}'}) + + # Get the list of issues from the GitHub API + issues_url = f'https://api.github.com/repos/{owner}/{repo}/issues' + params = { + 'state': 'all', # 'all' includes open and closed issues + 'per_page': 100, # Adjust as needed + } + all_issues = [] + + while True: + response = session.get(issues_url, params=params) + response.raise_for_status() + all_issues.extend(response.json()) + + # Check if there are more pages of issues + link_header = response.headers.get('Link', '') + if 'rel="next"' not in link_header: + break + + rx = re.compile(r'<(.[^>]+)>; *rel="next"') + + # Extract the URL for the next page + link = [l.strip() for l in link_header.split(',') if 'rel="next"' in l] + if len(link) > 0: + link = link[0] + issues_url = rx.match(link).group(1) + else: + response.close() + break + with open(PATH_GH_JSON, 'w') as f: + json.dump(all_issues, f) + + with open(PATH_GH_JSON, 'r') as f: + all_issues = json.load(f) pull_requests = [i for i in all_issues if 'pull_request' in i] issues = [i for i in all_issues if 'pull_request' not in i] # Filter issues within the date range - issues_created = [i for i in issues if - start_date <= datetime.datetime.strptime(i['created_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] - issues_closed = [i for i in issues if - i['closed_at'] and start_date <= datetime.datetime.strptime(i['closed_at'], '%Y-%m-%dT%H:%M:%SZ') <= end_date] + issues_created = [i for i in issues if start_date <= toDate(i['created_at']) <= end_date] + issues_updated = [i for i in issues if start_date <= toDate(i['updated_at']) <= end_date and toDate(i['created_at']) < start_date] + + + def printInfos(issues): + is_closed = [] + is_open = [] + is_duplicate = [] + is_wontfix = [] + for i in issues: + pass + is_closed = [i for i in issues_created if 'closed_at' in i and toDate(i['closed_at']) <= end_date] + is_open = [i for i in issues_created if i['closed_at'] > 0] + is_duplicate = [i for i in issues_created if i['closed_at'] > 0] + is_wontfix = [i for i in issues_created if i['closed_at'] > 0] + print(f' Total: {len(issues)}') + print(f' Open: {len(is_open)}') + print(f' Closed: {len(is_closed)}') + + print(f'Issues created in reporting period: {start_date} to {end_date}') + print(f'Total: {len(issues_created)}') + print(f'By today: {today}') + printInfos(issues_created) + + print(f'Issues created before {start_date} but handled in reporting period') + printInfos(issues_updated) - print(f'Issues {start_date} to {end_date}') - print(f'Created: {len(issues_created)}') - print(f'Closed: {len(issues_closed)}') return None @@ -363,44 +399,6 @@ def test_github_2(self): report_github_issues() - def test_github_issue(self): - - path_json = pathlib.Path(DIR_REPO_TMP) / 'issues.json' - - if not path_json.is_file(): - issues = [] - from github3api import GitHubAPI - client = GitHubAPI() - - for issue_slice in client.get('https://api.github.com/repos/EnMAP-Box/enmap-box/issues', - _get='all', - # _attributes = ['title', 'user', 'labels', 'html_url', 'state', 'locked', - # 'assignees', 'milestone', 'created_at', 'updated_at', 'closed_at', 'state_reason', 'pull_request'] - ): - if isinstance(issue_slice, dict): - issues.append(issue_slice) - else: - issues.extend(issue_slice) - - with open(path_json, 'w', encoding='utf-8') as f: - json.dump(issues, f) - else: - with open(path_json, 'r', encoding='utf-8') as f: - issues = json.load(f) - s = "" - s = "" - for issue in issues: - dtg_created = issue['created_at'] - dtg_updates = issue['updated_at'] - dtg_closed = issue['closed_at'] - state = issue['state'] - - s = "" - s = "" - # gh = github3.login(username='foo', password='bar') - # - # s = "" - if __name__ == "__main__": parser = argparse.ArgumentParser(description='Install testdata', formatter_class=argparse.RawTextHelpFormatter) From 9dd15e777e43442c63f15d0cfa6da1d70190e8d9 Mon Sep 17 00:00:00 2001 From: "Benjamin Jakimow benjamin.jakimow@geo.hu-berlin.de" Date: Wed, 6 Sep 2023 10:57:29 +0200 Subject: [PATCH 5/6] added report for QGIS repo issues Signed-off-by: Benjamin Jakimow benjamin.jakimow@geo.hu-berlin.de --- scripts/create_report.py | 195 ++++++++++++++++++++++++++++++++++----- 1 file changed, 173 insertions(+), 22 deletions(-) diff --git a/scripts/create_report.py b/scripts/create_report.py index 55971f99..bc701828 100644 --- a/scripts/create_report.py +++ b/scripts/create_report.py @@ -3,6 +3,8 @@ """ import argparse import csv +from typing import List, Dict + import requests import datetime import inspect @@ -14,6 +16,7 @@ import urllib.request import xml.etree.ElementTree as etree import pandas as pd + from xlsxwriter.workbook import Workbook from enmapbox import DIR_REPO_TMP @@ -93,7 +96,133 @@ def toDate(text, format: str = '%Y-%m-%dT%H:%M:%SZ') -> datetime.datetime: return datetime.datetime.strptime(text, format) -def report_github_issues() -> pd.DataFrame: +def report_github_issues_QGIS(authors=['jakimowb', 'janzandr']) -> pd.DataFrame: + """ + + is:issue created:2022-07-01..2022-12-31 + is:issue closed:2022-07-01..2022-12-31 + """ + + # GitHub repository owner and name + owner = 'qgis' + repo = 'QGIS' + + # Define the date range + start_date = toDate('2023-01-01', '%Y-%m-%d') + end_date = toDate('2023-06-30', '%Y-%m-%d') + + today = datetime.datetime.now().isoformat().split('T')[0] + + PATH_GH_JSON = pathlib.Path(__file__).parents[1] / 'tmp' / f'githubissues.{today}.QGIS.json' + + if not PATH_GH_JSON.is_file(): + os.makedirs(PATH_GH_JSON.parent, exist_ok=True) + # Your GitHub personal access token + assert 'GITHUB_TOKEN' in os.environ, 'GITHUB_TOKEN is not set. ' \ + 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' + token = os.environ['GITHUB_TOKEN'] + + # Create a session and set the authorization header + session = requests.Session() + session.headers.update({'Authorization': f'token {token}'}) + + # Get the list of issues from the GitHub API + issues_url = f'https://api.github.com/repos/{owner}/{repo}/issues' + params = { + 'state': 'all', # 'all' includes open and closed issues + 'per_page': 100, # Adjust as needed + 'creator': ','.join(authors), + } + all_issues = [] + + n_pages = 1 + while True: + print(f'Read page {n_pages}...') + response = session.get(issues_url, params=params) + + response.raise_for_status() + all_issues.extend(response.json()) + + # Check if there are more pages of issues + link_header = response.headers.get('Link', '') + if 'rel="next"' not in link_header: + break + + rx = re.compile(r'<(.[^>]+)>; *rel="next"') + + # Extract the URL for the next page + link = [l.strip() for l in link_header.split(',') if 'rel="next"' in l] + if len(link) > 0: + link = link[0] + issues_url = rx.match(link).group(1) + else: + response.close() + break + n_pages += 1 + with open(PATH_GH_JSON, 'w') as f: + json.dump(all_issues, f) + + with open(PATH_GH_JSON, 'r') as f: + all_issues = json.load(f) + + # filter by authors + + pull_requests = [i for i in all_issues if 'pull_request' in i] + issues = [i for i in all_issues if 'pull_request' not in i] + if True: + for i in issues: + if i['closed_at'] and toDate(i['closed_at']) > end_date: + i['closed_at'] = None + else: + s = "" + + # Filter issues within the date range + + created_in_report_period = [i for i in issues if start_date <= toDate(i['created_at']) <= end_date] + created_before_but_touched = [i for i in issues if toDate(i['created_at']) < start_date + and start_date <= toDate(i['updated_at']) <= end_date] + + + def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): + is_closed = [] + is_open = [] + + issues_by_label: Dict[str, List[dict]] = dict() + for i in issues: + if i['closed_at'] is None: + is_open.append(i) + else: + is_closed.append(i) + + for label in i['labels']: + n = label['name'] + issues_by_label[n] = issues_by_label.get(n, []) + [i] + + n_t = len(issues) + print(' Total: {:3}'.format(n_t)) + if n_t > 0: + n_o = len(is_open) + n_c = len(is_closed) + + print(' Open: {:3} {:0.2f}%'.format(n_o, n_o/n_t*100)) + print('Closed: {:3} {:0.2f}%'.format(n_c, n_c/n_t*100)) + for label in labels: + print(f' {label}: {len(issues_by_label.get(label, []))}') + + print(f'By today: {today}') + print(f'Issues created in reporting period: {start_date} to {end_date}:') + printInfos(created_in_report_period) + + print(f'Issues created before {start_date} but handled in reporting period:') + printInfos(created_before_but_touched) + + print(f'Total:') + printInfos(created_before_but_touched + created_in_report_period) + return None + + + +def report_github_issues_EnMAPBox() -> pd.DataFrame: """ is:issue created:2022-07-01..2022-12-31 @@ -161,36 +290,54 @@ def report_github_issues() -> pd.DataFrame: all_issues = json.load(f) pull_requests = [i for i in all_issues if 'pull_request' in i] issues = [i for i in all_issues if 'pull_request' not in i] + if True: + for i in issues: + if i['closed_at'] and toDate(i['closed_at']) > end_date: + i['closed_at'] = None + else: + s = "" + # Filter issues within the date range - issues_created = [i for i in issues if start_date <= toDate(i['created_at']) <= end_date] - issues_updated = [i for i in issues if start_date <= toDate(i['updated_at']) <= end_date and toDate(i['created_at']) < start_date] + created_in_report_period = [i for i in issues if start_date <= toDate(i['created_at']) <= end_date] + created_before_but_touched = [i for i in issues if toDate(i['created_at']) < start_date + and start_date <= toDate(i['updated_at']) <= end_date] - def printInfos(issues): + def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): is_closed = [] is_open = [] - is_duplicate = [] - is_wontfix = [] + + issues_by_label: Dict[str, List[dict]] = dict() for i in issues: - pass - is_closed = [i for i in issues_created if 'closed_at' in i and toDate(i['closed_at']) <= end_date] - is_open = [i for i in issues_created if i['closed_at'] > 0] - is_duplicate = [i for i in issues_created if i['closed_at'] > 0] - is_wontfix = [i for i in issues_created if i['closed_at'] > 0] - print(f' Total: {len(issues)}') - print(f' Open: {len(is_open)}') - print(f' Closed: {len(is_closed)}') - - print(f'Issues created in reporting period: {start_date} to {end_date}') - print(f'Total: {len(issues_created)}') + if i['closed_at'] is None: + is_open.append(i) + else: + is_closed.append(i) + + for label in i['labels']: + n = label['name'] + issues_by_label[n] = issues_by_label.get(n, []) + [i] + + n_t = len(issues) + n_o = len(is_open) + n_c = len(is_closed) + print(' Total: {:3}'.format(n_t)) + print(' Open: {:3} {:0.2f}%'.format(n_o, n_o/n_t*100)) + print('Closed: {:3} {:0.2f}%'.format(n_c, n_c/n_t*100)) + for label in labels: + print(f' {label}: {len(issues_by_label.get(label, []))}') + print(f'By today: {today}') - printInfos(issues_created) + print(f'Issues created in reporting period: {start_date} to {end_date}:') + printInfos(created_in_report_period) - print(f'Issues created before {start_date} but handled in reporting period') - printInfos(issues_updated) + print(f'Issues created before {start_date} but handled in reporting period:') + printInfos(created_before_but_touched) + print(f'Total:') + printInfos(created_before_but_touched + created_in_report_period) return None @@ -395,9 +542,13 @@ def byKey(ISSUES: list, key: str) -> dict: class TestCases(unittest.TestCase): - def test_github_2(self): + def test_github_EnMAPBox(self): + + report_github_issues_EnMAPBox() + + def test_github_QGIS(self): - report_github_issues() + report_github_issues_QGIS() if __name__ == "__main__": From b99c85204ce22628df6698efba1913a7af7b4d2d Mon Sep 17 00:00:00 2001 From: jakimowb Date: Wed, 6 Sep 2023 22:14:18 +0200 Subject: [PATCH 6/6] flake8 Signed-off-by: jakimowb --- scripts/create_report.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/scripts/create_report.py b/scripts/create_report.py index bc701828..840c6374 100644 --- a/scripts/create_report.py +++ b/scripts/create_report.py @@ -182,7 +182,6 @@ def report_github_issues_QGIS(authors=['jakimowb', 'janzandr']) -> pd.DataFrame: created_before_but_touched = [i for i in issues if toDate(i['created_at']) < start_date and start_date <= toDate(i['updated_at']) <= end_date] - def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): is_closed = [] is_open = [] @@ -204,8 +203,8 @@ def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): n_o = len(is_open) n_c = len(is_closed) - print(' Open: {:3} {:0.2f}%'.format(n_o, n_o/n_t*100)) - print('Closed: {:3} {:0.2f}%'.format(n_c, n_c/n_t*100)) + print(' Open: {:3} {:0.2f}%'.format(n_o, n_o / n_t * 100)) + print('Closed: {:3} {:0.2f}%'.format(n_c, n_c / n_t * 100)) for label in labels: print(f' {label}: {len(issues_by_label.get(label, []))}') @@ -216,12 +215,11 @@ def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): print(f'Issues created before {start_date} but handled in reporting period:') printInfos(created_before_but_touched) - print(f'Total:') + print('Total:') printInfos(created_before_but_touched + created_in_report_period) return None - def report_github_issues_EnMAPBox() -> pd.DataFrame: """ @@ -248,8 +246,6 @@ def report_github_issues_EnMAPBox() -> pd.DataFrame: 'Read https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens for details.' token = os.environ['GITHUB_TOKEN'] - - # Create a session and set the authorization header session = requests.Session() session.headers.update({'Authorization': f'token {token}'}) @@ -297,14 +293,12 @@ def report_github_issues_EnMAPBox() -> pd.DataFrame: else: s = "" - # Filter issues within the date range created_in_report_period = [i for i in issues if start_date <= toDate(i['created_at']) <= end_date] created_before_but_touched = [i for i in issues if toDate(i['created_at']) < start_date and start_date <= toDate(i['updated_at']) <= end_date] - def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): is_closed = [] is_open = [] @@ -324,8 +318,8 @@ def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): n_o = len(is_open) n_c = len(is_closed) print(' Total: {:3}'.format(n_t)) - print(' Open: {:3} {:0.2f}%'.format(n_o, n_o/n_t*100)) - print('Closed: {:3} {:0.2f}%'.format(n_c, n_c/n_t*100)) + print(' Open: {:3} {:0.2f}%'.format(n_o, n_o / n_t * 100)) + print('Closed: {:3} {:0.2f}%'.format(n_c, n_c / n_t * 100)) for label in labels: print(f' {label}: {len(issues_by_label.get(label, []))}') @@ -336,7 +330,7 @@ def printInfos(issues: List[dict], labels=['duplicate', 'wontfix']): print(f'Issues created before {start_date} but handled in reporting period:') printInfos(created_before_but_touched) - print(f'Total:') + print('Total:') printInfos(created_before_but_touched + created_in_report_period) return None @@ -543,11 +537,9 @@ def byKey(ISSUES: list, key: str) -> dict: class TestCases(unittest.TestCase): def test_github_EnMAPBox(self): - report_github_issues_EnMAPBox() def test_github_QGIS(self): - report_github_issues_QGIS()