Browse Source

Don't call sys.platform so many times ...

Making it a function parameter will make it a testable function
oz123 11 years ago
parent
commit
f260df5ff1
1 changed files with 9 additions and 6 deletions
  1. 9 6
      scripts/pwman3

+ 9 - 6
scripts/pwman3

@@ -34,11 +34,12 @@ from pwman import default_config, which
 
 _saveconfig = True
 
-def get_ui_platform():
-    if 'darwin' in sys.platform:
+
+def get_ui_platform(platform):
+    if 'darwin' in platform:
         from pwman.ui.mac import PwmanCliMacNew as PwmanCliNew
         OSX = True
-    elif 'win' in sys.platform:
+    elif 'win' in platform:
         from pwman.ui.win import PwmanCliWinNew as PwmanCliNew
         OSX = False
     else:
@@ -47,6 +48,7 @@ def get_ui_platform():
 
     return PwmanCliNew, OSX
 
+
 def parser_options():
     parser = argparse.ArgumentParser(description=('pwman3 - a command line '
                                                   'password manager.'))
@@ -64,12 +66,13 @@ def parser_options():
                               " 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('-t', '--test',  help=("Run pwman from current directory "
-                                               "without installation"),
+    parser.add_argument('-t', '--test', help=("Run pwman from current directory "
+                                              "without installation"),
                         action="store_true")
 
     return parser
 
+
 def get_conf_options(args, OSX):
 
     config_dir = os.path.expanduser("~/.pwman")
@@ -125,7 +128,7 @@ args = parser_options().parse_args()
 if args.test:
     sys.path.insert(0, os.getcwd())
 
-PwmanCliNew, OSX = get_ui_platform()
+PwmanCliNew, OSX = get_ui_platform(sys.platform)
 
 try:
     xselpath, dbtype = get_conf_options(args, OSX)