From 607015c9c1ea51280ca4453f502ffe54525f4a55 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 7 May 2006 19:29:57 +0000 Subject: [PATCH] Added --add-version option. This allows you to add an implementation to an existing interface without having a local file. The new implementation is added right after the last existing one in the file. To add an archive at the same time: $ 0publish --add-version=1.2 --archive-url=http://site/prog-1.2.tgz iface.xml git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/trunk/0publish@878 9f8c893c-44ee-0310-b757-c8ca8341c71e --- 0publish | 4 ++++ release.py | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/0publish b/0publish index 3d3ae1d..c9a9336 100755 --- a/0publish +++ b/0publish @@ -9,6 +9,7 @@ import edit, validator version = '0.3' parser = OptionParser(usage="usage: %prog [options] interface") +parser.add_option("--add-version", help="add a new implementation", action='store', metavar='VERSION') parser.add_option("--archive-url", help="add archive at this URL", action='store', metavar='URL') parser.add_option("--archive-file", help="local copy of archive-url", action='store', metavar='FILE') parser.add_option("--archive-extract", help="subdirectory of archive to extract", action='store', metavar='DIR') @@ -118,6 +119,9 @@ if options.gpgsign: if options.key: print "Changing key from '%s' to '%s'" % (key, options.key) key = options.key +if options.add_version: + import release + data = release.add_version(data, options.add_version) if options.set_id or options.set_version or options.set_released or \ options.set_stability or options.set_arch or options.set_main: import release diff --git a/release.py b/release.py index db1fa9e..b3fb039 100644 --- a/release.py +++ b/release.py @@ -1,9 +1,28 @@ -from xml.dom import minidom +from xml.dom import minidom, Node from zeroinstall.injector import namespaces, model import time, re date_format = '\d{4}-\d{2}-\d{2}' +def add_version(data, version): + """Create a new after the last one in the file.""" + doc = minidom.parseString(data) + all_impls = doc.documentElement.getElementsByTagNameNS(namespaces.XMLNS_IFACE, 'implementation') + if not all_impls: + raise Exception('No existing elements found!') + new_impl = doc.createElementNS(namespaces.XMLNS_IFACE, 'implementation') + new_impl.setAttribute('version', version) + new_impl.setAttribute('id', '.') + + last_impl = all_impls[-1] + previous = last_impl.previousSibling + next = last_impl.nextSibling + parent = last_impl.parentNode + if previous and previous.nodeType == Node.TEXT_NODE: + parent.insertBefore(doc.createTextNode(previous.nodeValue), next) + parent.insertBefore(new_impl, next) + return doc.toxml() + def make_release(data, id, version, released, stability, main, arch): """Normally there's only one implementation, but we can cope with several.""" if released == 'today': released = time.strftime('%Y-%m-%d') -- 2.11.4.GIT