[blivet:master 04/12] Use values for keyword arguments to CryptSetup.

mulhern amulhern at redhat.com
Mon Apr 28 22:26:42 UTC 2014


Do not bother to give the values names.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devicelibs/crypto.py | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/blivet/devicelibs/crypto.py b/blivet/devicelibs/crypto.py
index f561c96..ebe2197 100644
--- a/blivet/devicelibs/crypto.py
+++ b/blivet/devicelibs/crypto.py
@@ -48,26 +48,17 @@ def generateBackupPassphrase():
         parts.append(raw[i : i + 5])
     return "-".join(parts)
 
-def askyes(question):
-    return True
-
-def dolog(priority, text):
-    pass
-
-def askpassphrase(text):
-    return None
-
 def is_luks(device):
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     return cs.isLuks()
 
 def luks_uuid(device):
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     return cs.luksUUID()
 
 def luks_status(name):
     """True means active, False means inactive (or non-existent)"""
-    cs = CryptSetup(name=name, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(name=name, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     return cs.status()
 
 def luks_format(device,
@@ -76,7 +67,7 @@ def luks_format(device,
     if not passphrase:
         raise ValueError("luks_format requires passphrase")
 
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
 
     #None is not considered as default value and pycryptsetup doesn't accept it
     #so we need to filter out all Nones
@@ -108,14 +99,14 @@ def luks_open(device, name, passphrase=None, key_file=None):
     if not passphrase:
         raise ValueError("luks_format requires passphrase")
 
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
 
     rc = cs.activate(passphrase=passphrase, name=name)
     if rc<0:
         raise CryptoError("luks_open failed for %s (%s) with errno %d" % (device, name, rc))
 
 def luks_close(name):
-    cs = CryptSetup(name=name, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(name=name, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     rc = cs.deactivate()
 
     if rc:
@@ -128,7 +119,7 @@ def luks_add_key(device,
     if not passphrase:
         raise ValueError("luks_add_key requires passphrase")
 
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     rc = cs.addKeyByPassphrase(passphrase=passphrase, newPassphrase=new_passphrase)
 
     if rc<0:
@@ -141,7 +132,7 @@ def luks_remove_key(device,
     if not passphrase:
         raise ValueError("luks_remove_key requires passphrase")
 
-    cs = CryptSetup(device=device, yesDialog=askyes, logFunc=dolog, passwordDialog=askpassphrase)
+    cs = CryptSetup(device=device, yesDialog=lambda x: True, logFunc=lambda p, t: None, passwordDialog=lambda x: None)
     rc = cs.removePassphrase(passphrase = passphrase)
 
     if rc:
-- 
1.8.3.1



More information about the anaconda-patches mailing list