Pārlūkot izejas kodu

Remove config access from do_new

oz123 10 gadi atpakaļ
vecāks
revīzija
51d9222788
3 mainītis faili ar 4 papildinājumiem un 9 dzēšanām
  1. 2 2
      pwman/ui/base.py
  2. 0 1
      pwman/ui/cli.py
  3. 2 6
      pwman/ui/tools.py

+ 2 - 2
pwman/ui/base.py

@@ -512,7 +512,7 @@ class BaseCommands(BaseUI, HelpUI):
                     raise Exception(errmsg)
                 password = self.get_password(argsgiven=1, **args)
             else:
-                numerics, leet, s_chars = get_pass_conf()
+                numerics, leet, s_chars = get_pass_conf(self.config)
                 password = self.get_password(argsgiven=0,
                                              numerics=numerics,
                                              leetify=leet,
@@ -592,7 +592,7 @@ class BaseCommands(BaseUI, HelpUI):
         return tools.getpassword("Password (Blank to generate): ",
                                  reader=reader, length=length, leetify=leetify,
                                  special_signs=special_signs, symbols=symbols,
-                                 numerics=numerics)
+                                 numerics=numerics, config=self.config)
 
 
 class Aliases(BaseCommands):  # pragma: no cover

+ 0 - 1
pwman/ui/cli.py

@@ -25,7 +25,6 @@ Define the CLI interface for pwman3 and the helper functions
 from __future__ import print_function
 import pwman
 from pwman.util.crypto_engine import CryptoEngine
-import pwman.util.config as config
 import sys
 import cmd
 from pwman.ui.base import Aliases, BaseCommands

+ 2 - 6
pwman/ui/tools.py

@@ -21,7 +21,6 @@ Define the CLI interface for pwman3 and the helper functions
 """
 from __future__ import print_function
 from pwman.util.callback import Callback
-import pwman.util.config as config
 import subprocess as sp
 import getpass
 import sys
@@ -146,10 +145,7 @@ def getpassword(question, argsgiven=None,
                 width=_defaultwidth, echo=False,
                 reader=getpass.getpass, numerics=False, leetify=False,
                 symbols=False, special_signs=False,
-                length=None):  # pragma: no cover
-    # TODO: getpassword should recieve a config insatnce
-    #       and generate the policy according to it,
-    #       so that getpassword in cli would be simplified
+                length=None, config=None):  # pragma: no cover
     if argsgiven == 1 or length:
         while not length:
             try:
@@ -174,7 +170,7 @@ def getpassword(question, argsgiven=None,
             return getpassword(
                 '', argsgiven=1, width=width, echo=echo, reader=reader,
                 numerics=numerics, leetify=leetify, symbols=symbols,
-                special_signs=special_signs, length=length)
+                special_signs=special_signs, length=length, config=config)
         a2 = reader("[Repeat] %s" % (question.ljust(width)))
         if a1 == a2:
             if leetify: