__init__.py 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
  18. #============================================================================
  19. # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
  20. #============================================================================
  21. import os
  22. import pkg_resources
  23. import argparse
  24. appname = "Pwman3"
  25. try:
  26. version = pkg_resources.get_distribution('pwman3').version
  27. except pkg_resources.DistributionNotFound: # pragma: no cover
  28. version = "0.5"
  29. website = "http://github.com/pwman3/pwman3"
  30. author = "Oz Nahum"
  31. authoremail = "nahumoz@gmail.com"
  32. description = "Pwman -a command line password management application."
  33. keywords = "password management sqlite crypto"
  34. def which(cmd):
  35. _, cmdname = os.path.split(cmd)
  36. for path in os.environ["PATH"].split(os.pathsep):
  37. cmd = os.path.join(path, cmdname)
  38. if os.path.isfile(cmd) and os.access(cmd, os.X_OK): # pragma: no cover
  39. return cmd
  40. config_dir = os.path.expanduser("~/.pwman")
  41. default_config = {'Global': {'umask': '0100', 'colors': 'yes',
  42. 'cls_timeout': '5',
  43. 'save': 'True'
  44. },
  45. 'Database': {'type': 'SQLite',
  46. 'filename': os.path.join(config_dir,
  47. "pwman.db")},
  48. 'Encryption': {'algorithm': 'AES'},
  49. 'Readline': {'history': os.path.join(config_dir,
  50. "history")}
  51. }
  52. def parser_options():
  53. parser = argparse.ArgumentParser(description=('pwman3 - a command line '
  54. 'password manager.'))
  55. parser.add_argument('-c', '--config', dest='cfile',
  56. default=os.path.expanduser("~/.pwman/config"),
  57. help='cofiguration file to read')
  58. parser.add_argument('-d', '--database', dest='dbase')
  59. parser.add_argument('-e', '--encryption', dest="algo",
  60. help=("Possible options are: AES(default), ARC2, ARC4,"
  61. " Blowfish, CAST, DES, DES3, IDEA, RC5"))
  62. parser.add_argument('-k', '--convert', dest='dbconvert',
  63. action='store_true', default=False,
  64. # os.path.expanduser('~/.pwman/pwman.db'),
  65. help=("Convert old DB format to version >= 0.4."
  66. " The database that will be converted is the"
  67. " one found in the config file, or the one given"
  68. " as command line argument."))
  69. parser.add_argument('-O', '--output', dest='output',
  70. #default=os.path.expanduser('~/.pwman/pwman-newdb.db'),
  71. help=("The name of the newly created database after "
  72. "converting."))
  73. return parser