2 from zeroinstall
.injector
import gpg
3 from optparse
import OptionParser
6 from logging
import info
, debug
11 parser
= OptionParser(usage
="usage: %prog [options] interface")
12 parser
.add_option("-k", "--key", help="key to use for signing")
13 parser
.add_option("-e", "--edit", help="edit with $EDITOR", action
='store_true')
14 parser
.add_option("-r", "--release", help="set versions and dates", action
='store_true')
15 parser
.add_option("-x", "--xmlsign", help="add an XML signature block", action
='store_true')
16 parser
.add_option("-v", "--verbose", help="more verbose output", action
='count')
17 parser
.add_option("-V", "--version", help="display version information", action
='store_true')
19 (options
, args
) = parser
.parse_args()
22 print "0publish (zero-install) " + version
23 print "Copyright (C) 2005 Thomas Leonard"
24 print "This program comes with ABSOLUTELY NO WARRANTY,"
25 print "to the extent permitted by law."
26 print "You may redistribute copies of this program"
27 print "under the terms of the GNU General Public License."
28 print "For more information about these matters, see the file named COPYING."
33 logger
= logging
.getLogger()
34 if options
.verbose
== 1:
35 logger
.setLevel(logging
.INFO
)
37 logger
.setLevel(logging
.DEBUG
)
46 ans
= raw_input(q
+ " [Y/N] ").lower()
47 if ans
in ('y', 'yes'): return True
48 if ans
in ('n', 'no'): return False
50 # Load or create the starting data...
52 if os
.path
.exists(interface
):
53 contents
= file(interface
).read()
54 data
, sign_fn
, key
= signing
.check_signature(interface
)
56 if confirm("Interface file '%s' does not exist. Create it?" % interface
):
57 from create
import create
58 data
= create(interface
)
59 sign_fn
= signing
.sign_unsigned
65 debug("Original data: %s", data
)
66 info("Original signing method: %s", sign_fn
.__name
__)
67 info("Original key: %s", key
)
74 # Validate the input...
78 except validator
.InvalidInterface
, ex
:
79 print "Invalid interface: " + str(ex
)
82 ans
= raw_input("Interface is invalid. (E)dit or (A)bort?").lower()
83 if ans
in ('e', 'edit'):
84 data
= edit
.edit(data
)
85 options
.edit
= False # Don't edit twice
87 if ans
in ('a', 'abort'): sys
.exit(1)
91 sign_fn
= signing
.sign_xml
93 print "Changing key from '%s' to '%s'" % (key
, options
.key
)
97 data
= release
.make_release(data
)
99 data
= edit
.edit(data
)
102 # Validate the result...
104 validator
.check(data
)
106 except validator
.InvalidInterface
, ex
:
107 print "Invalid interface: " + str(ex
)
110 ans
= raw_input("Interface is invalid. (E)dit or (A)bort?").lower()
111 if ans
in ('e', 'edit'):
112 data
= edit
.edit(data
)
114 if ans
in ('a', 'abort'): sys
.exit(1)
117 if old_data
== data
and sign_fn
== old_sign_fn
and key
== old_key
:
118 print "Interface unchanged. Not writing."
122 sign_fn(interface
, data
, key
)
124 print "Wrote", interface