Pārlūkot izejas kodu

Merge pull request #30 from hbrunn/add-configurable-default-pw-length

Allow changing default password length, 

Thanks, Holger!
Oz 10 gadi atpakaļ
vecāks
revīzija
0ff9e30306
2 mainītis faili ar 13 papildinājumiem un 1 dzēšanām
  1. 8 0
      README.md
  2. 5 1
      pwman/ui/tools.py

+ 8 - 0
README.md

@@ -148,6 +148,14 @@ The config file  must have the following option:
      Password length (default 7): 7
      New password: Q1dab@7
      ``` 
+ 
+ * Default password length can be changed by: 
+
+    ```
+    [Generator]
+    default_pw_length = 42
+    ```
+
    
  * Copying password to X11 or Mac clip board:
   - On Mac OSX systems copying utilizes `pbcopy`  

+ 5 - 1
pwman/ui/tools.py

@@ -147,7 +147,11 @@ def getpassword(question, argsgiven=None,
     if argsgiven == 1 or length:
         while not length:
             try:
-                length = getinput("Password length (default 7): ", default='7')
+                default_length = config.get_value(
+                    'Generator', 'default_pw_length') or '7'
+                length = getinput(
+                    "Password length (default %s): " % default_length,
+                    default=default_length)
                 length = int(length)
             except ValueError:
                 print("please enter a proper integer")