Răsfoiți Sursa

Move _saveconfig into the Config dictionary

This will ease the migration of all the functions
into a module and away from the launcher script.
oz123 11 ani în urmă
părinte
comite
7937f8b0d3
2 a modificat fișierele cu 7 adăugiri și 10 ștergeri
  1. 2 1
      pwman/__init__.py
  2. 5 9
      scripts/pwman3

+ 2 - 1
pwman/__init__.py

@@ -45,7 +45,8 @@ def which(cmd):
 config_dir = os.path.expanduser("~/.pwman")
 
 default_config = {'Global': {'umask': '0100', 'colors': 'yes',
-                             'cls_timeout': '5'
+                             'cls_timeout': '5',
+                             'save': 'True'
                              },
                   'Database': {'type': 'SQLite',
                                'filename': os.path.join(config_dir,

+ 5 - 9
scripts/pwman3

@@ -26,7 +26,6 @@ import sys
 import re
 import shutil
 
-_saveconfig = True
 
 _db_warn = ("pwman3 detected that are using the old database format"
             " which is insecure."
@@ -66,7 +65,7 @@ def parser_options():
     return parser
 
 
-def get_conf():
+def get_conf(args):
     config_dir = os.path.expanduser("~/.pwman")
 
     if not os.path.isdir(config_dir):
@@ -112,22 +111,19 @@ def set_umask(config):
 
 
 def set_db(args):
-    global _saveconfig
     if args.dbase:
         config.set_value("Database", "filename", args.dbase)
-        _saveconfig = False
+        config.set_value("Global", "save", "False")
 
 
 def set_algorithm(args, config):
-    global _saveconfig
     if args.algo:
         config.set_value("Encryption", "algorithm", args.algo)
-        _saveconfig = False
-
+        config.set_value("Global", "save", "False")
 
 def get_conf_options(args, OSX):
 
-    config = get_conf()
+    config = get_conf(args)
     xselpath = config.get_value("Global", "xsel")
     if not xselpath:
         set_xsel(config, OSX)
@@ -216,7 +212,7 @@ def main(args):
     except KeyboardInterrupt, e:
         print(e)
 
-    if _saveconfig:
+    if config.get_value("Global", "save") == "True":
         try:
             config.save(args.cfile)
         except Exception, e: