Browse Source

Changes to initialize text UI with config instance

oz123 10 years ago
parent
commit
35f33a7fe1
2 changed files with 12 additions and 6 deletions
  1. 5 4
      pwman/__init__.py
  2. 7 2
      pwman/ui/cli.py

+ 5 - 4
pwman/__init__.py

@@ -96,7 +96,8 @@ def parser_options(formatter_class=argparse.HelpFormatter):
                               " one found in the config file, or the one given"
                               " one found in the config file, or the one given"
                               " as command line argument."))
                               " as command line argument."))
     parser.add_argument('-O', '--output', dest='output',
     parser.add_argument('-O', '--output', dest='output',
-                        # default=os.path.expanduser('~/.pwman/pwman-newdb.db'),
+                        # default=os.path.expanduser(
+                        #'~/.pwman/pwman-newdb.db'),
                         help=("The name of the newly created database after "
                         help=("The name of the newly created database after "
                               "converting."))
                               "converting."))
     return parser
     return parser
@@ -110,10 +111,10 @@ def get_conf_file(args):
 
 
     if not os.path.exists(args.cfile):
     if not os.path.exists(args.cfile):
         config.set_config(default_config)
         config.set_config(default_config)
+        return config
     else:
     else:
-        config.load(args.cfile)
-
-    return config
+        configp = config.Config(args.cfile)
+        return configp
 
 
 
 
 def set_xsel(config, OSX):
 def set_xsel(config, OSX):

+ 7 - 2
pwman/ui/cli.py

@@ -41,7 +41,7 @@ class PwmanCliNew(cmd.Cmd, Aliases, BaseCommands):
     """
     """
     Inherit from the BaseCommands and Aliases
     Inherit from the BaseCommands and Aliases
     """
     """
-    def __init__(self, db, hasxsel, callback):
+    def __init__(self, db, hasxsel, callback, config_parser=None):
         """
         """
         initialize CLI interface, set up the DB
         initialize CLI interface, set up the DB
         connecion, see if we have xsel ...
         connecion, see if we have xsel ...
@@ -49,8 +49,13 @@ class PwmanCliNew(cmd.Cmd, Aliases, BaseCommands):
         cmd.Cmd.__init__(self)
         cmd.Cmd.__init__(self)
         self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
         self.intro = "%s %s (c) visit: %s" % (pwman.appname, pwman.version,
                                               pwman.website)
                                               pwman.website)
-        self._historyfile = config.get_value("Readline", "history")
+        if not config_parser:
+            self._historyfile = config.get_value("Readline", "history")
+        else:
+            self._historyfile = config_parser.get_value("Readline", "history")
+
         self.hasxsel = hasxsel
         self.hasxsel = hasxsel
+        self.config = config_parser
         try:
         try:
             enc = CryptoEngine.get()
             enc = CryptoEngine.get()
             enc.callback = callback()
             enc.callback = callback()