Просмотр исходного кода

Remove saving of configuration from command Line

Users should use an editor to edit the config file
oz123 10 лет назад
Родитель
Сommit
e5a2ce8588
2 измененных файлов с 3 добавлено и 29 удалено
  1. 3 23
      pwman/util/config.py
  2. 0 6
      scripts/pwman3

+ 3 - 23
pwman/util/config.py

@@ -97,29 +97,9 @@ class Config(object):
     def set_value(self, section, name, value):
         self.parser.set(section, name, value)
 
-
-
-
-def save(filename=None):
-    """Save the configuration to 'filename'."""
-    global _conf, _file
-    if not filename:
-        filename = _file
-
-    parser = ConfigParser()
-    for key in _conf.keys():
-        if not parser.has_section(key):
-            parser.add_section(key)
-        sectiondict = _conf[key]
-        if isinstance(sectiondict, dict):
-            for optionkey in sectiondict.keys():
-                parser.set(key, optionkey, str(sectiondict[optionkey]))
-    try:
-        fp = open(filename, "w+")
-        parser.write(fp)
-        fp.close()
-    except IOError as e:
-        raise ConfigException(str(e))
+    def save(self, filename):
+        with open(filename, "w+") as fp:
+            self.parser.write(fp)
 
 
 def get_pass_conf(config):

+ 0 - 6
scripts/pwman3

@@ -46,12 +46,6 @@ def main(args):
     except KeyboardInterrupt as e:
         print(e)
 
-    if config.get_value("Global", "save") == "True":
-        try:
-            config.save(args.cfile)
-        except Exception as e:
-            print ("Error: %s" % e)
-            sys.exit(-1)
 
 if __name__ == '__main__':
     args = parser_options().parse_args()