Skip to content

Instantly share code, notes, and snippets.

@Naxela
Last active August 31, 2022 21:04
Show Gist options
  • Save Naxela/e9493314254cb33a536f58e775bc4fc8 to your computer and use it in GitHub Desktop.
Save Naxela/e9493314254cb33a536f58e775bc4fc8 to your computer and use it in GitHub Desktop.
Make quick release notes for A3D from github
import bpy, json
from urllib.request import urlopen
def decapitalize(s, upper_rest = False):
return ''.join([s[:1].lower(), (s[1:].upper() if upper_rest else s[1:])])
def cap(s):
return ' '.join(w[:1].upper() + w[1:] for w in s.split(' '))
Changes = []
Fixes = []
Voids = []
#The amount of pages to fetch. Usually at the current pace of PR's, 1 or 2 is usually enough.
#Each page lists 100 PR's and usually less is made in a month.
pages_to_fetch = 1
#The month you want to create release notes for
#in number format, i.e. 01 is january, 08 is august, etc.
month = '07'
#The REST api url to the Armory Engine repo
html = "https://api.github.com/repos/armory3d/armory/pulls?state=closed&per_page=100&page="
html_url = html + str(pages_to_fetch)
#For each page, we create an object that we can merge later
html = urlopen(html_url).read()
content = json.loads(html)
#---------------------------------
# For each entry
for PR in range(len(content)):
# If the entry is merged (Closed)
if content[PR]['merged_at']:
#Check the date it was merged
date = content[PR]['merged_at'].split("T")
date = date[0].split("-")
if date[1] == month:
#Format
#<li><p class="uk-text-default"><span class=" uk-text-bold"><a href="https://github.com/armory3d/armory/pull/$PRNumber">#$PRNumber</a></span> - $Owner added $Title</p></li>
#print(content[PR]['labels'][0]['name'])
PR_Number = str(content[PR]['number'])
Owner = cap(str(content[PR]['user']['login']))
Title = decapitalize(str(content[PR]['title']))
Entry = '<li><p class="uk-text-default"><span class="uk-text-bold"><a href="https://github.com/armory3d/armory/pull/{pr}">#{pr}</a></span> - {owner} added {title}</p></li>'.format(pr=PR_Number, owner=Owner, title=Title)
if content[PR]['labels']:
#If the PR is a change
if "Changes" in (content[PR]['labels'][0]['name']):
#print("PR is a change")
Changes.append(Entry)
#If the PR is a fix
if "Fixes" in (content[PR]['labels'][0]['name']):
#print("PR is a fix")
Fixes.append(Entry)
#If the PR is void (without labels)
if not content[PR]['labels']:
Voids.append(Entry)
#Write this to an HTML file that can be copied into the notes.html
list = open(r"C:\Users\kleem\Desktop\ArmoryNews6\entries.html", "w+")
for entry in Changes:
list.write(entry)
list.write("\n")
list.write("\n")
list.write("\n")
for entry in Fixes:
list.write(entry)
list.write("\n")
list.write("\n")
list.write("\n")
for entry in Voids:
list.write(entry)
list.write("\n")
list.close()
#print(Changes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment