Skip to content

Commit

Permalink
Refactor a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
esteele committed Jul 2, 2012
1 parent abc5ca4 commit 6898ee5
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions unifyChangelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
from docutils.core import publish_doctree
import sys

dist_url = "http://dist.plone.org/release/%s/versions.cfg"

def pullVersions(versionsFile):

def pullVersions(versionNumber):
try:
from ordereddict import OrderedDict
packageVersions = OrderedDict()
except ImportError:
print "Unable to find OrderedDict"
packageVersions = {}
url = dist_url % versionNumber
versionsFile = urllib.urlopen(url)
for line in versionsFile:
line = line.strip().replace(" ", "")
if line and not (line.startswith('#') or line.startswith('[')):
Expand All @@ -23,6 +27,7 @@ def pullVersions(versionsFile):
pass
else:
packageVersions[package] = version
print "Parsed %s" % url
return packageVersions


Expand All @@ -43,7 +48,7 @@ def getSourceLocation(packageName):
url = value[0].split()[1]
else:
variable = value[1][2:-1].split()[0].split(':')

section, option = variable
value[1] = config.get(section, option)
url = ''.join(value[1:])
Expand All @@ -55,39 +60,22 @@ def getSourceLocation(packageName):
url = url.replace('git:', 'https:')
url = url.replace('.git', '')
return url, branch
# sources = {}
# for line in sourcesFile:
# line = line.strip().replace(" ","")
# for t in ['svn','git']:
# line = line.replace("=%s" % t,";;")

# if line and not (line.startswith('#') or line.startswith('[')):
# try:
# package, location = line.split(";;")
# sources[package] = location
# except ValueError:
# print line
return "", ""


def main(argv):
priorVersionNumber = sys.argv[1]
currentVersionNumber = sys.argv[2]

dist_url = "http://dist.plone.org/release/%s/versions.cfg"
priorVersionsFile = urllib.urlopen(dist_url % priorVersionNumber)
priorVersions = pullVersions(priorVersionsFile)

currentVersionsFile = urllib.urlopen(dist_url % currentVersionNumber)
currentVersions = pullVersions(currentVersionsFile)
priorVersions = pullVersions(priorVersionNumber)
currentVersions = pullVersions(currentVersionNumber)

# sourcesFile = open("sources.cfg", "r")
# sources = pullSources #pullSources(sourcesFile)
outputStr = ""
for package, version in currentVersions.iteritems():
if package in priorVersions:
priorVersion = priorVersions[package]
if version > priorVersion:
print "%s has a newer version" % package
packageChange = u"%s: %s %s %s" % (package, priorVersion, u"\u2192", version)
outputStr += u"\n" + packageChange + u"\n" + u"-" * len(packageChange) + "\n"
source, branch = getSourceLocation(package)
Expand Down

0 comments on commit 6898ee5

Please sign in to comment.