Quellcode durchsuchen

Reorganise the startup script

 * The function parser_options is now in
   pwman/__init__.py so it is importable.
   This is needed for building the man page
 * The parser_options no longer includes -t option.
   This option is redundant. Instead when developing
   one should use virtualenv.
oz123 vor 11 Jahren
Ursprung
Commit
4c938742d5
2 geänderte Dateien mit 33 neuen und 40 gelöschten Zeilen
  1. 25 0
      pwman/__init__.py
  2. 8 40
      scripts/pwman3

+ 25 - 0
pwman/__init__.py

@@ -20,6 +20,7 @@
 #============================================================================
 import os
 import pkg_resources
+import argparse
 
 appname = "Pwman3"
 try:
@@ -55,3 +56,27 @@ default_config = {'Global': {'umask': '0100', 'colors': 'yes',
                   'Readline': {'history': os.path.join(config_dir,
                                                        "history")}
                   }
+
+
+def parser_options():
+    parser = argparse.ArgumentParser(description=('pwman3 - a command line '
+                                                  'password manager.'))
+    parser.add_argument('-c', '--config', dest='cfile',
+                        default=os.path.expanduser("~/.pwman/config"),
+                        help='cofiguration file to read')
+    parser.add_argument('-d', '--database', dest='dbase')
+    parser.add_argument('-e', '--encryption', dest="algo",
+                        help=("Possible options are: AES(default), ARC2, ARC4,"
+                              " Blowfish, CAST, DES, DES3, IDEA, RC5"))
+    parser.add_argument('-k', '--convert', dest='dbconvert',
+                        action='store_true', default=False,
+                        # os.path.expanduser('~/.pwman/pwman.db'),
+                        help=("Convert old DB format to version >= 0.4."
+                              " The database that will be converted is the"
+                              " one found in the config file, or the one given"
+                              " as command line argument."))
+    parser.add_argument('-O', '--output', dest='output',
+                        #default=os.path.expanduser('~/.pwman/pwman-newdb.db'),
+                        help=("The name of the newly created database after "
+                              "converting."))
+    return parser

+ 8 - 40
scripts/pwman3

@@ -21,11 +21,17 @@
 #============================================================================
 from __future__ import print_function
 import os
-import argparse
 import sys
 import re
 import shutil
-
+from pwman import default_config, which
+from pwman import parser_options
+from pwman.ui import get_ui_platform
+from pwman.ui.tools import CLICallback
+import pwman.util.config as config
+import pwman.data.factory
+from pwman.data.convertdb import PwmanConvertDB
+from pwman.util.crypto import CryptoEngine
 
 _db_warn = ("pwman3 detected that are using the old database format"
             " which is insecure."
@@ -37,34 +43,6 @@ _db_warn = ("pwman3 detected that are using the old database format"
             )
 
 
-def parser_options():
-    parser = argparse.ArgumentParser(description=('pwman3 - a command line '
-                                                  'password manager.'))
-    parser.add_argument('-c', '--config', dest='cfile',
-                        default=os.path.expanduser("~/.pwman/config"),
-                        help='cofiguration file to read')
-    parser.add_argument('-d', '--database', dest='dbase')
-    parser.add_argument('-e', '--encryption', dest="algo",
-                        help=("Possible options are: AES(default), ARC2, ARC4,"
-                              " Blowfish, CAST, DES, DES3, IDEA, RC5"))
-    parser.add_argument('-k', '--convert', dest='dbconvert',
-                        action='store_true', default=False,
-                        # os.path.expanduser('~/.pwman/pwman.db'),
-                        help=("Convert old DB format to version >= 0.4."
-                              " The database that will be converted is the"
-                              " one found in the config file, or the one given"
-                              " as command line argument."))
-    parser.add_argument('-O', '--output', dest='output',
-                        #default=os.path.expanduser('~/.pwman/pwman-newdb.db'),
-                        help=("The name of the newly created database after "
-                              "converting."))
-    parser.add_argument('-t', '--test', help=("Run pwman from current"
-                                              " directory"
-                                              " without installation"),
-                        action="store_true")
-    return parser
-
-
 def get_conf(args):
     config_dir = os.path.expanduser("~/.pwman")
 
@@ -221,14 +199,4 @@ def main(args):
 
 if __name__ == '__main__':
     args = parser_options().parse_args()
-    if args.test:
-        sys.path.insert(0, os.getcwd())
-
-    from pwman import default_config, which
-    from pwman.ui import get_ui_platform
-    from pwman.ui.tools import CLICallback
-    import pwman.util.config as config
-    import pwman.data.factory
-    from pwman.data.convertdb import PwmanConvertDB
-    from pwman.util.crypto import CryptoEngine
     main(args)