gpgsigner.py ported to Python 3 #10

Merged
merged 1 commit into from May 4, 2011

2 participants

@therealplato

Some libraries were renamed or changed:
xmlrpclib was changed to xmlrpc.client
StringIO was changed to io


Python 3 makes a distinction between strings and bytes. stdin accepts
bytes which must be encoded from our input string. stdout returns bytes
which must be decoded into our output string.

(note - UTF8 encoding is the default and is used here, it may not be the
best choice. This script is untested on Python 2.x.)

Pipe challenge to gpg's stdin:
old: p1.stdin.write(input)
new: p1.stdin.write(bytes(input, 'UTF8'))

Pipe gpg's output to the XMLRPC call:
old: pasteid = s.pastes.newPaste('text',output)
new: pasteid = s.pastes.newPaste('text',output.decode())


Finally, the print statement is now a print() function:
old: print "http://paste.pocoo.org/raw/%s/" % (pasteid)
new: print ("http://paste.pocoo.org/raw/",pasteid,"/", sep="")

@nanotube nanotube merged commit e87743d into nanotube:master May 4, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment