chiark / gitweb /
pwsafe: Some simple reformatting.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 24 May 2015 15:45:32 +0000 (16:45 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 28 May 2015 10:21:01 +0000 (11:21 +0100)
pwsafe

diff --git a/pwsafe b/pwsafe
index d4a4547fa8077a64b609e10b278a6e5988b743da..4bdc83ef9ac0ef39f365ca155fdc66370af4cb1f 100644 (file)
--- a/pwsafe
+++ b/pwsafe
@@ -75,39 +75,28 @@ def cmd_create(av):
   except GetoptError:
     return 1
   for o, a in opts:
   except GetoptError:
     return 1
   for o, a in opts:
-    if o in ('-c', '--cipher'):
-      cipher = a
-    elif o in ('-m', '--mac'):
-      mac = a
-    elif o in ('-h', '--hash'):
-      hash = a
-    else:
-      raise 'Barf!'
-  if len(args) > 2:
-    return 1
-  if len(args) >= 1:
-    tag = args[0]
-  else:
-    tag = 'pwsafe'
+    if o in ('-c', '--cipher'): cipher = a
+    elif o in ('-m', '--mac'): mac = a
+    elif o in ('-h', '--hash'): hash = a
+    else: raise 'Barf!'
+  if len(args) > 2: return 1
+  if len(args) >= 1: tag = args[0]
+  else: tag = 'pwsafe'
 
   ## Set up the database.
   if mac is None: mac = hash + '-hmac'
   PW.create(file, C.gcciphers[cipher], C.gchashes[hash], C.gcmacs[mac], tag)
 
 def cmd_changepp(av):
 
   ## Set up the database.
   if mac is None: mac = hash + '-hmac'
   PW.create(file, C.gcciphers[cipher], C.gchashes[hash], C.gcmacs[mac], tag)
 
 def cmd_changepp(av):
-  if len(av) != 0:
-    return 1
+  if len(av) != 0: return 1
   pw = PW(file, writep = True)
   pw.changepp()
 
 def cmd_find(av):
   pw = PW(file, writep = True)
   pw.changepp()
 
 def cmd_find(av):
-  if len(av) != 1:
-    return 1
+  if len(av) != 1: return 1
   pw = PW(file)
   pw = PW(file)
-  try:
-    print pw[av[0]]
-  except KeyError, exc:
-    die('Password `%s\' not found.' % exc.args[0])
+  try: print pw[av[0]]
+  except KeyError, exc: die("Password `%s' not found." % exc.args[0])
 
 def cmd_store(av):
   if len(av) < 1 or len(av) > 2:
 
 def cmd_store(av):
   if len(av) < 1 or len(av) > 2:
@@ -116,8 +105,7 @@ def cmd_store(av):
   if len(av) < 2:
     pp = C.getpass("Enter passphrase `%s': " % tag)
     vpp = C.getpass("Confirm passphrase `%s': " % tag)
   if len(av) < 2:
     pp = C.getpass("Enter passphrase `%s': " % tag)
     vpp = C.getpass("Confirm passphrase `%s': " % tag)
-    if pp != vpp:
-      raise ValueError, "passphrases don't match"
+    if pp != vpp: raise ValueError, "passphrases don't match"
   elif av[1] == '-':
     pp = stdin.readline()
   else:
   elif av[1] == '-':
     pp = stdin.readline()
   else:
@@ -126,55 +114,40 @@ def cmd_store(av):
   pw[av[0]] = chomp(pp)
 
 def cmd_copy(av):
   pw[av[0]] = chomp(pp)
 
 def cmd_copy(av):
-  if len(av) < 1 or len(av) > 2:
-    return 1
+  if len(av) < 1 or len(av) > 2: return 1
   pw_in = PW(file)
   pw_out = PW(av[0], 'w')
   pw_in = PW(file)
   pw_out = PW(av[0], 'w')
-  if len(av) >= 3:
-    pat = av[1]
-  else:
-    pat = None
+  if len(av) >= 3: pat = av[1]
+  else: pat = None
   for k in pw_in:
   for k in pw_in:
-    if pat is None or fnmatch(k, pat):
-      pw_out[k] = pw_in[k]
+    if pat is None or fnmatch(k, pat): pw_out[k] = pw_in[k]
 
 def cmd_list(av):
 
 def cmd_list(av):
-  if len(av) > 1:
-    return 1
+  if len(av) > 1: return 1
   pw = PW(file)
   pw = PW(file)
-  if len(av) >= 1:
-    pat = av[0]
-  else:
-    pat = None
+  if len(av) >= 1: pat = av[0]
+  else: pat = None
   for k in pw:
   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):
 
 def cmd_topixie(av):
-  if len(av) > 2:
-    return 1
+  if len(av) > 2: return 1
   pw = PW(file)
   pix = C.Pixie()
   if len(av) == 0:
   pw = PW(file)
   pix = C.Pixie()
   if len(av) == 0:
-    for tag in pw:
-      pix.set(tag, pw[tag])
+    for tag in pw: pix.set(tag, pw[tag])
   else:
     tag = av[0]
   else:
     tag = av[0]
-    if len(av) >= 2:
-      pptag = av[1]
-    else:
-      pptag = av[0]
+    if len(av) >= 2: pptag = av[1]
+    else: pptag = av[0]
     pix.set(pptag, pw[tag])
 
 def cmd_del(av):
     pix.set(pptag, pw[tag])
 
 def cmd_del(av):
-  if len(av) != 1:
-    return 1
+  if len(av) != 1: return 1
   pw = PW(file, writep = True)
   tag = av[0]
   pw = PW(file, writep = True)
   tag = av[0]
-  try:
-    del pw[tag]
-  except KeyError, exc:
-    die('Password `%s\' not found.' % exc.args[0])
+  try: del pw[tag]
+  except KeyError, exc: die("Password `%s' not found." % exc.args[0])
 
 commands = { 'create': [cmd_create,
                         '[-c CIPHER] [-h HASH] [-m MAC] [PP-TAG]'],
 
 commands = { 'create': [cmd_create,
                         '[-c CIPHER] [-h HASH] [-m MAC] [PP-TAG]'],