Selaa lähdekoodia

Relocate the class CLICallBack

oz123 10 vuotta sitten
vanhempi
commit
7e63036c4b
2 muutettua tiedostoa jossa 15 lisäystä ja 14 poistoa
  1. 2 14
      pwman/data/convertdb.py
  2. 13 0
      pwman/util/callback.py

+ 2 - 14
pwman/data/convertdb.py

@@ -20,10 +20,9 @@ from __future__ import print_function
 import os
 import shutil
 import time
-import getpass
 from pwman.util.crypto import CryptoEngine
 import pwman.data.factory
-from pwman.util.callback import Callback
+from pwman.util.callback import CLICallback
 from pwman.data.nodes import NewNode
 from pwman.data.tags import Tag
 from pwman.data.database import Database, DatabaseException
@@ -173,17 +172,6 @@ class SQLiteDatabaseReader(Database):
             return keyrow[0]
 
 
-class CLICallback(Callback):
-    def getinput(self, question):
-        return raw_input(question)
-
-    def getsecret(self, question):
-        return getpass.getpass(question + ":")
-
-    def getnewsecret(self, question):
-        return getpass.getpass(question + ":")
-
-
 class DBConverter(object):
     """
     A general class to provide a base template for converting a database
@@ -264,7 +252,7 @@ class PwmanConvertDB(DBConverter):
         enc = CryptoEngine.get()
         self.oldkey = enc.get_cryptedkey()
         self.newdb.savekey(self.oldkey)
-    
+
     def convert_nodes(self):
         """convert old nodes instances to new format"""
         self.NewNodes = []

+ 13 - 0
pwman/util/callback.py

@@ -25,6 +25,8 @@ Callback interface
 To be used when UI needs to be back to get info from user.
 """
 
+import getpass
+
 
 # this class is just a base class no real method to test
 class Callback(object):  # pragma: no cover
@@ -48,3 +50,14 @@ class Callback(object):  # pragma: no cover
     def notice(self, warning):
         """Present notice to user"""
         pass
+
+
+class CLICallback(Callback):
+    def getinput(self, question):
+        return raw_input(question)
+
+    def getsecret(self, question):
+        return getpass.getpass(question + ":")
+
+    def getnewsecret(self, question):
+        return getpass.getpass(question + ":")