Example #1
0
def get_conf(args):
    for dir in config.find_config_dir('pwman'):
        if not os.path.isdir(dir):  # pragma: no cover
            os.makedirs(dir, exist_ok=True)

    configp = config.Config(args.cfile, config.default_config)
    return configp
Example #2
0
def parser_options(formatter_class=argparse.HelpFormatter):  # pragma: no cover
    parser = argparse.ArgumentParser(prog='pwman3',
                                     description=description,
                                     formatter_class=formatter_class)
    parser.add_argument('-c',
                        '--config',
                        dest='cfile',
                        default=os.path.join(
                            config.find_config_dir('pwman')[0], 'config'),
                        help='cofiguration file to read')
    parser.add_argument('-d', '--database', dest='dbase')
    parser.add_argument('-i',
                        '--import',
                        nargs=2,
                        dest='file_delim',
                        help="Specify the file name and the delimeter type")
    subparsers = parser.add_subparsers(help='commands', dest="cmd")

    printer = subparsers.add_parser('p', help='print password entry')
    printer.add_argument("node", type=int)

    copy = subparsers.add_parser('cp', help='copy password entry to clipboard')
    copy.add_argument("node", type=int)

    version = subparsers.add_parser('version', help='version')
    version.add_argument("--latest", action='store_true')
    return parser
Example #3
0
    def test_windows_platfrom(self):

        with unittest.mock.patch('platform.system') as pl:
            pl.return_value = 'Windows'
            os.environ['APPDATA'] = 'balls'
            cdir, data_dir = config.find_config_dir('zzzz')

            self.assertEqual(
                os.path.expandvars(os.path.join('$APPDATA', 'zzzz')), cdir)
Example #4
0
    def test_windows_platfrom(self):

        with unittest.mock.patch('platform.system') as pl:
            pl.return_value = 'Windows'
            os.environ['APPDATA'] = 'balls'
            cdir, data_dir = config.find_config_dir('zzzz')

            self.assertEqual(
                os.path.expandvars(os.path.join('$APPDATA', 'zzzz')),
                cdir)
Example #5
0
 def test_new_scheme(self):
     # assert we get xdg_fine with Linux
     cdir, data_dir = config.find_config_dir('zzzz_posix')
     self.assertEqual(cdir, os.path.expanduser("~/.config/zzzz_posix"))
Example #6
0
 def test_compat(self):
     cdir, data_dir = config.find_config_dir('zzzz_compat_posix')
     self.assertEqual(self.c_path, cdir)
Example #7
0
 def test_has_user_db(self):
     self.assertNotEqual(os.path.join(config.find_config_dir("pwman")[1],'pwman.db'),
                         self.conf.get_value('Database', 'filename'))
Example #8
0
 def test_has_user_history(self):
     ddir = find_config_dir('pwman')[1]
     path = os.path.join(ddir, "history")
     config = self.conf.get_value('Readline', 'history')
     self.assertEqual(path, config)
Example #9
0
 def test_new_scheme(self):
     # assert we get xdg_fine with Linux
     cdir, data_dir = config.find_config_dir('zzzz_posix')
     self.assertEqual(cdir, os.path.expanduser("~/.config/zzzz_posix"))
Example #10
0
 def test_compat(self):
     cdir, data_dir = config.find_config_dir('zzzz_compat_posix')
     self.assertEqual(self.c_path, cdir)
Example #11
0
 def test_has_user_db(self):
     self.assertNotEqual(
         os.path.join(config.find_config_dir("pwman")[1], 'pwman.db'),
         self.conf.get_value('Database', 'filename'))
Example #12
0
 def test_has_user_history(self):
     ddir = find_config_dir('pwman')[1]
     path = os.path.join(ddir, "history")
     config = self.conf.get_value('Readline', 'history')
     self.assertEqual(path, config)