浏览代码

Allow changing default password length

Holger Brunn 10 年之前
父节点
当前提交
d1117dfcf1
共有 2 个文件被更改,包括 13 次插入1 次删除
  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

@@ -146,7 +146,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")