def moan(msg):
"""Issue a warning message MSG."""
- print >>stderr, '%s: %s' % (prog, msg)
+ stderr.write('%s: %s\n' % (prog, msg))
def die(msg):
"""Report MSG as a fatal error, and exit."""
def cmd_find(av):
if len(av) != 1: return 1
with PW(file) as pw:
- try: print pw[av[0]]
+ try: print(pw[av[0]])
except KeyError: die("Password `%s' not found" % _excval().args[0])
def cmd_store(av):
if len(av) >= 1: pat = av[0]
else: pat = None
for k in pw:
- if pat is None or fnmatch(k, pat): print k
+ if pat is None or fnmatch(k, pat): print(k)
def cmd_topixie(av):
if len(av) > 2: return 1
### Command-line handling and dispatch.
def version():
- print '%s 1.0.0' % prog
- print 'Backend types: %s' % \
- ' '.join([c.NAME for c in StorageBackend.classes()])
+ print('%s 1.0.0' % prog)
+ print('Backend types: %s' %
+ ' '.join([c.NAME for c in StorageBackend.classes()]))
def usage(fp):
- print >>fp, 'Usage: %s COMMAND [ARGS...]' % prog
+ fp.write('Usage: %s COMMAND [ARGS...]\n' % prog)
def help():
version()
- print
+ print('')
usage(stdout)
- print '''
+ print('''
Maintains passwords or other short secrets securely.
Options:
-f, --file=FILE Where to find the password-safe file.
Commands provided:
-'''
+''')
for c in sorted(commands):
- print '%s %s' % (c, commands[c][1])
+ print('%s %s' % (c, commands[c][1]))
## Choose a default database file.
if 'PWSAFE' in environ:
c = 'find'
try:
if commands[c][0](argv):
- print >>stderr, 'Usage: %s %s %s' % (prog, c, commands[c][1])
+ stderr.write('Usage: %s %s %s\n' % (prog, c, commands[c][1]))
exit(1)
except DecryptError:
die("decryption failure")