Created
April 18, 2013 10:14
-
-
Save Svenito/5411659 to your computer and use it in GitHub Desktop.
Script gets the changes between two build versions of Houdini from the journal and outputs them in a more traditional changelog format. Be sensible with how much data you want to get! Requires the Beautiful soup and requests libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
from BeautifulSoup import BeautifulSoup | |
from textwrap import TextWrapper | |
import requests | |
import collections | |
import sys | |
import re | |
def print_changelog(version, start, end): | |
template_url = 'http://www.sidefx.com/index2.php?option=com_journal&Itemid=213&page=index&journal=default&logfile=ALL&perpage=9999&start=0&icon=ALL&search=&view=PRN&version={}&buildstart={}&buildend={}' | |
url = template_url.format(version, start, end) | |
content = requests.get(url) | |
soup = BeautifulSoup(content.text) | |
plain_text = ''.join(soup.findAll(text=True)) | |
release_notes = {} | |
changes_it = iter(plain_text.split('\n')) | |
for line in changes_it: | |
# skip blank lines, comments, short descriptions and | |
# then extract the version | |
if (line and | |
not re.match(r'^\sThe \S+', line) and | |
not re.match(r' Ending boiler plate', line) and | |
not re.match(r'\w+, \w+ \d{1,2}, \d{4}', line) | |
): | |
m = re.match(r'Houdini (\d+\.\d+\.\d+):', line) | |
if m: | |
change_version = m.group(1) | |
release_notes.setdefault(change_version, []) | |
release_notes[change_version].append(changes_it.next().strip()) | |
od = collections.OrderedDict(sorted(release_notes.items(), reverse=True)) | |
print 'Changelog between Houdini version {0}.{1} and {0}.{2}'.format(version, start, end) | |
for k, v in od.iteritems(): | |
wrapper = TextWrapper(initial_indent="* ", | |
subsequent_indent=' ', | |
width=80) | |
print k | |
print '----------' | |
for line in v: | |
print '\n'.join(wrapper.wrap(line)) | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
print("changelog.py <version> <startbuild> <endbuild>\n" | |
"\nExample:\n" | |
"changelog 12.5 371 376\n") | |
sys.exit(0) | |
version = sys.argv[1] | |
start_build = sys.argv[2] | |
end_build = sys.argv[3] | |
print_changelog(version, start_build, end_build) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment