From e52d94bea9cb7129d545d78e7d684926ddae8c67 Mon Sep 17 00:00:00 2001 From: Ben Parsons Date: Mon, 25 Jun 2018 15:00:58 +0100 Subject: [PATCH 1/2] ignore malformed PR items --- scripts/proposals.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/proposals.py b/scripts/proposals.py index b489f0d2..a8f58cae 100755 --- a/scripts/proposals.py +++ b/scripts/proposals.py @@ -63,7 +63,6 @@ for label in labels: for item in issues[label]: # set the created date, find local field, otherwise Github - print(item) body = str(item['body']) created = re.search('^Date: (.+?)\n', body, flags=re.MULTILINE) if created is not None: @@ -133,16 +132,22 @@ for label in labels: text_file.write(" - " + str(shepherd) + "\n") # PRs - pr_list = re.search('PRs: (.+?)$', str(item['body'])) - if pr_list is not None: - pr_list_formatted = set() - pr_list = pr_list.group(1) - for p in pr_list.split(","): - prs.add(p.strip()) - pr_list_formatted.add("`PR" + str(p.strip()) + "`_") - text_file.write(" - " + ', '.join(pr_list_formatted)) - text_file.write("\n") - else: + try: + pr_list = re.search('PRs: (.+?)$', str(item['body'])) + if pr_list is not None: + pr_list_formatted = set() + pr_list = pr_list.group(1) + for p in pr_list.split(","): + if not re.match(r"#\d", p.strip()): + raise RuntimeWarning + prs.add(p.strip()) + pr_list_formatted.add("`PR" + str(p.strip()) + "`_") + text_file.write(" - " + ', '.join(pr_list_formatted)) + text_file.write("\n") + else: + text_file.write(" - \n") + except: + print("exception parsing PRs for MSC" + str(item['number'])) text_file.write(" - \n") text_file.write("\n\n\n") From d7919b6989847297c0c29b00529d2b67bd9d64b0 Mon Sep 17 00:00:00 2001 From: Ben Parsons Date: Tue, 31 Jul 2018 15:08:42 +0100 Subject: [PATCH 2/2] also scrape PRs when the full URL is pasted --- scripts/proposals.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/proposals.py b/scripts/proposals.py index a8f58cae..d8c1aa24 100755 --- a/scripts/proposals.py +++ b/scripts/proposals.py @@ -138,10 +138,15 @@ for label in labels: pr_list_formatted = set() pr_list = pr_list.group(1) for p in pr_list.split(","): - if not re.match(r"#\d", p.strip()): + if re.match(r"#\d", p.strip()): + prs.add(p.strip()) + pr_list_formatted.add("`PR" + str(p.strip()) + "`_") + elif re.match(r"https://github.com/matrix-org/matrix-doc/pulls/\d", p.strip()): + pr = "#" + p.strip().replace('https://github.com/matrix-org/matrix-doc/pulls/', '') + prs.add(pr) + pr_list_formatted.add("`PR" + str(pr) + "`_") + else: raise RuntimeWarning - prs.add(p.strip()) - pr_list_formatted.add("`PR" + str(p.strip()) + "`_") text_file.write(" - " + ', '.join(pr_list_formatted)) text_file.write("\n") else: