From 2323b28b60f0c820ebc135210c443fbff6c9ea79 Mon Sep 17 00:00:00 2001 From: Sarah M Brown Date: Sun, 15 Oct 2023 18:18:44 -0400 Subject: [PATCH] progress report --- badges.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ config.py | 6 +++-- tasktracking.py | 9 ++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/badges.py b/badges.py index 3ace88b..90f5fa9 100644 --- a/badges.py +++ b/badges.py @@ -1,8 +1,14 @@ import click from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey from cryptography.exceptions import InvalidSignature +from .config import gh_approvers import json + +badge_types = ['review', 'practice', 'explore', 'experience', + 'build', 'lab','community'] + + @click.command() @click.option('-b','--badge-name',help="name of the badge formated like type.YYYY-MM-DD") @click.option('-a','--approver',help='github username of the badge issuer') @@ -94,6 +100,60 @@ def process_badges(json_output,file_out = None): # author = review_df['author'].apply(pd.Series) + +@click.command() +@click.option('-j','--json-output',default='badges.json',type=click.File('r'), + help='json file to parse') +@click.option('-f','--file-out',default=None,type=click.File('w'), + help='to write to a file, otherwise will echo') + +def get_approved_titles(json_output,file_out = None): + ''' + process gh cli json + + Parameters + ---------- + json_output : filename + file generated from `gh pr list -s all --json title,latestReviews ` + file_out : file name + file to be generated and store the output + ''' + + with open(json_output, 'r') as f: + PR_list = json.load(f) + + #filter for ones with reviews + reviewed = [(pr['title'], pr['latestReviews'][0]) + for pr in PR_list if pr['latestReviews']] + # filter to only process approved ones latestReviews.state + # extract title, latestReviews.author.login, latestReviews.body, + logged_badges = [title for title,review in reviewed + if review['state'] == 'APPROVED' and + review['author']['login']in gh_approvers] + + out_list = '\n'.join(logged_badges) + + if file_out: + titles_by_type = {bt:[t for t in logged_badges if type in t.lower()] + for bt in badge_types} + verified_by_type = '\n'.join(['## '+bt + ' ('+str(len(bl)) +')' +'\n - '+'\n - '. join(bl) + for bt,bl in titles_by_type.items()]) + valid_badges = [vi for v in titles_by_type.values() for vi in v] + not_typed = [p for p in logged_badges if not(p in valid_badges)] + with open(file_out,'w') as f: + f.write('## all approved ') + f.write(out_list) + f.write(verified_by_type) + f.write('## Cannot match as a typed badge') + f.write('\n- ' + '\n - '.join(not_typed)) + else: + click.echo(out_list) + +block_template = ''' +# {type} +''' + + # # Put this in student repos # on: diff --git a/config.py b/config.py index e53ce72..9cbdfdb 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,5 @@ -repo = 'http://introcompsys.github.io/fall2022/' -base_url = 'https://raw.githubusercontent.com/introcompsys/fall2022/main/_' +repo = 'http://introcompsys.github.io/fall2023/' +base_url = 'https://raw.githubusercontent.com/introcompsys/fall2023/main/_' + +gh_approvers = ['brownsarahm','ascott20','marcinpawlukiewicz'] diff --git a/tasktracking.py b/tasktracking.py index 0ee8473..471acd1 100644 --- a/tasktracking.py +++ b/tasktracking.py @@ -149,6 +149,15 @@ def get_assignment(date, assignment_type = 'prepare'): # help='date should be YYYY-MM-DD of the tasks you want and must be valid') def fetch_to_checklist(date, assignment_type = 'prepare'): + ''' + get assignment text and change numbered items to a checklist + + Parameters + ---------- + date : string + YYYY-MM-DD formatted strings of the date to get + assignment_type : + ''' path = base_url +assignment_type + '/' + date +'.md'