From 05be08940319f43808b9cdbcc5cdcd317e5c8d2e Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 1 Jan 2006 22:22:17 +0000 Subject: [PATCH] Editing is now supported. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/injector/0publish@623 9f8c893c-44ee-0310-b757-c8ca8341c71e --- 0publish | 3 +++ edit.py | 17 +++++++++++++++++ signing.py | 14 +++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 edit.py diff --git a/0publish b/0publish index 1ab02c3..ebb0809 100755 --- a/0publish +++ b/0publish @@ -55,6 +55,9 @@ if options.xmlsign: if options.key: print "Changing key from '%s' to '%s'" % (key, options.key) key = options.key +if options.edit: + import edit + data = edit.edit(data) print "Data", data print "Sign", sign_fn diff --git a/edit.py b/edit.py new file mode 100644 index 0000000..334d936 --- /dev/null +++ b/edit.py @@ -0,0 +1,17 @@ +import tempfile, os + +def edit(data): + fd, tmp = tempfile.mkstemp(prefix = '0publish-') + try: + stream = os.fdopen(fd, 'w') + stream.write(data) + stream.close() + editor = os.environ.get('EDITOR', 'vi') + if os.spawnlp(os.P_WAIT, editor, editor, tmp): + raise Exception('Editing with $EDITOR ("%s") failed') + new_data = file(tmp).read() + finally: + os.unlink(tmp) + if new_data == data: + raise Exception('Data unchanged after edit. Aborting.') + return new_data diff --git a/signing.py b/signing.py index 62cb7bc..aaf981a 100644 --- a/signing.py +++ b/signing.py @@ -3,17 +3,21 @@ import tempfile, os, base64 def check_signature(path): data = file(path).read() - if data.startswith('BEGIN'): - data_stream, sigs = gpg.check_stream(file(path)) - sign_fn = sign_plain - elif '\n