Welcome, guest | Sign In | My Account | Store | Cart
#!/usr/bin/env python

import base64
import sys

encode_or_decode = 'encode' in sys.argv[0].lower() and base64.encode or 'decode' in sys.argv[0].lower() and base64.decode or (sys.stderr.write("Error: script name must contain 'encode' or 'decode'!\n") or sys.exit(-1))

encode_or_decode(len(sys.argv) > 1 and open(sys.argv[1]) or sys.stdin, len(sys.argv) > 2 and open(sys.argv[2],'w') or sys.stdout)

Diff to Previous Revision

--- revision 1 2011-03-29 20:57:25
+++ revision 2 2013-04-26 09:37:21
@@ -5,4 +5,4 @@
 
 encode_or_decode = 'encode' in sys.argv[0].lower() and base64.encode or 'decode' in sys.argv[0].lower() and base64.decode or (sys.stderr.write("Error: script name must contain 'encode' or 'decode'!\n") or sys.exit(-1))
 
-encode_or_decode(len(sys.argv)>1 and open(sys.argv[1]) or sys.stdin, len(sys.argv)>2 and open(sys.argv[2],'w') or sys.stdout)
+encode_or_decode(len(sys.argv) > 1 and open(sys.argv[1]) or sys.stdin, len(sys.argv) > 2 and open(sys.argv[2],'w') or sys.stdout)

History