Ver código fonte

change how metadata is read

Oz N Tiram 9 anos atrás
pai
commit
5edb2ade2e
3 arquivos alterados com 41 adições e 21 exclusões
  1. 24 11
      pwman/__init__.py
  2. 3 4
      pwman/ui/cli.py
  3. 14 6
      setup.py

+ 24 - 11
pwman/__init__.py

@@ -22,6 +22,7 @@ import os
 import argparse
 import sys
 import re
+import string
 import colorama
 import pkg_resources
 from pwman.util import config
@@ -34,17 +35,29 @@ try:
 except pkg_resources.DistributionNotFound:  # pragma: no cover
     version = "0.7.2"
 
-website = "http://pwman3.github.io/pwman3/"
-author = "Oz Nahum Tiram"
-authoremail = "nahumoz@gmail.com"
-description = "a command line password manager with support for multiple databases."
-keywords = "password management sqlite crypto"
-long_description = u"""
-Pwman3 aims to provide a simple but powerful commandline interface for
-password management.
-It allows one to store passwords in database locked by master password which
-is AES encrypted.
-Pwman3 supports MySQL, Postgresql and SQLite"""
+
+class PkgMetadata(object):
+
+    def __init__(self):
+        p = pkg_resources.get_distribution('pwman3')
+        f = open(os.path.join(p.location+'-info','PKG-INFO'))
+        lines = f.readlines()
+        self.summary = lines[3].split(':')[-1].strip()
+        self.description = ''.join(map(string.strip, lines[9:14]))
+        self.author_email = lines[6].split(':')[-1].strip()
+        self.author = lines[5].split(':')[-1].strip()
+        self.home_page = lines[4].split(':')[-1].strip()
+
+try:
+    pkg_meta = PkgMetadata()
+    website = pkg_meta.home_page
+    author = pkg_meta.author
+    authoremail = pkg_meta.author_email
+    description = pkg_meta.summary
+    long_description = pkg_meta.description
+except IOError as E:
+    # this should only happen once when installing the package
+    pass
 
 
 def which(cmd):  # pragma: no cover

+ 3 - 4
pwman/ui/cli.py

@@ -33,8 +33,7 @@ except ImportError as e:  # pragma: no cover
 
 
 from pwman.ui.baseui import BaseCommands
-from pwman import (get_conf_options, get_db_version, version, appname,
-                   parser_options, website)
+from pwman import (get_conf_options, get_db_version, version, pkg_meta, parser_options)
 from pwman.ui.tools import CLICallback
 from pwman.data import factory
 from pwman.exchange.importer import Importer
@@ -54,8 +53,8 @@ class PwmanCli(cmd.Cmd, BaseCommands):
         connecion, see if we have xsel ...
         """
         super(PwmanCli, self).__init__(**kwargs)
-        self.intro = "%s %s (c) visit: %s" % (appname, version,
-                                              website)
+        self.intro = "%s %s (c) visit: %s" % ('pwman3', version,
+                                              pkg_meta.home_page)
         self._historyfile = config_parser.get_value("Readline", "history")
         self.hasxsel = hasxsel
         self.config = config_parser

+ 14 - 6
setup.py

@@ -325,13 +325,21 @@ if sys.platform.startswith('win'):
     install_requires.append('pyreadeline')
 
 
-setup(name=pwman.appname,
+long_description = u"""\
+Pwman3 aims to provide a simple but powerful commandline interface for
+password management.
+It allows one to store passwords in database locked by master password which
+is AES encrypted.
+Pwman3 supports MySQL, Postgresql and SQLite"""
+
+
+setup(name='pwman3',
       version='0.7.3.dev',
-      description=pwman.description,
-      long_description=pwman.long_description,
-      author=pwman.author,
-      author_email=pwman.authoremail,
-      url=pwman.website,
+      description = "a command line password manager with support for multiple databases.",
+      long_description=long_description,
+      author='Oz Nahum Tiram',
+      author_email='nahumoz@gmail.com',
+      url='http://pwman3.github.io/pwman3/',
       license="GNU GPL",
       packages=find_packages(exclude=['tests']),
       include_package_data=True,