From 67a217151450c6d41ca03c434458e8cf5ea4b578 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 23 Jun 2013 10:15:35 +0200 Subject: o Creating a parent pom for my code. --- plugins_to_xml.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 plugins_to_xml.py (limited to 'plugins_to_xml.py') diff --git a/plugins_to_xml.py b/plugins_to_xml.py new file mode 100644 index 0000000..0173e81 --- /dev/null +++ b/plugins_to_xml.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +import json +import sys +# pip install --user semantic_version +from semantic_version import Version +import collections + +data = json.load(sys.stdin) + +docs = data["response"]["docs"] + +#print json.dumps(docs, indent=2) +def info(msg): + print >> sys.stderr, msg + +info('Found ' + str(len(docs)) + ' artifacts') + +# Some magic hacks to get semantic_version to like the versions more +def v(doc): + return doc["v"]. \ + replace("alpha1", "0.alpha-1"). \ + replace("alpha2", "0.alpha-2") + +found = {} +for doc in docs: + key = doc["g"] + ":" + doc["a"] + prev = found.get(key) + if prev == None: + found[key] = doc +# print "First version of " + key + " => " + str(Version.coerce(doc["v"])) + continue + + oldV = Version.coerce(v(prev)) +# print "oldV=" + str(oldV) + newV = Version.coerce(v(doc)) +# print "newV=" + str(newV) + + if newV > oldV: +# print "newer version of " + key + " => " + str(newV) + found[key] = doc +# else: +# print "old version of " + key + " => " + str(newV) + +found = collections.OrderedDict(sorted(found.items())) + +print "" +print "" +for key, p in found.iteritems(): + print """ + %(g)s + %(a)s + %(v)s + """ % p +print " " +print "" -- cgit v1.2.3