diff --git a/README.txt b/README.txt index 2861c89..32c73e0 100644 --- a/README.txt +++ b/README.txt @@ -1,20 +1,11 @@ -This file is for you to describe the ddportfolioservice -application. Typically you would include information such as the -information below: -Installation and Setup -====================== +This is the source code for the Debian Member Portfolio Service +application [0]. -Install ``ddportfolioservice`` using easy_install:: +Cf. https://debian-member-portfolio-service.readthedocs.org/ for more +documentation (or its source in docs/source/devdocs.rst), including +how to configure a development environment. - easy_install ddportfolioservice -Make a config file as follows:: +[0] http://wiki.debian.org/DDPortfolio - paster make-config ddportfolioservice config.ini - -Tweak the config file as appropriate and then setup the application:: - - paster setup-app config.ini - -Then you are ready to go. diff --git a/ddportfolioservice/model/keyfinder.py b/ddportfolioservice/model/keyfinder.py index d857f4d..71f584a 100644 --- a/ddportfolioservice/model/keyfinder.py +++ b/ddportfolioservice/model/keyfinder.py @@ -26,6 +26,7 @@ given keyring. """ import logging import time +import sys db = None cachetimestamp = 0 @@ -84,3 +85,25 @@ def getLoginByFingerprint(fpr): Gets the login associated with the given fingerprint if available. """ return _get_cached('login:fpr:%s' % fpr) + +def _dump_cache(): + cache = _get_keyring_cache() + fprs = [] + for key in cache.keys(): + if key.startswith('email:fpr:'): + fpr = key.replace('email:fpr:', '') + if not fpr in fprs: + fprs.append(fpr) + + for fpr in fprs: + login = getLoginByFingerprint(fpr) + email = _get_cached('email:fpr:%s' % fpr) + name = _get_cached('name:fpr:%s' % fpr) + + print fpr, login, ':' + print ' ', name, email + + +if __name__ == '__main__': + logging.basicConfig(stream=sys.stderr, level=logging.WARNING) + _dump_cache() diff --git a/ddportfolioservice/model/keyringanalyzer.py b/ddportfolioservice/model/keyringanalyzer.py index cc501c6..9f3aa69 100644 --- a/ddportfolioservice/model/keyringanalyzer.py +++ b/ddportfolioservice/model/keyringanalyzer.py @@ -35,6 +35,7 @@ import os.path import logging import subprocess import sys +import email.utils def _get_keyrings(): @@ -58,22 +59,8 @@ def _parse_uid(uid): Parse a uid of the form 'Real Name ' into email and realname parts. """ - uid = uid.strip() - # First, strip comment - s = uid.find('(') - e = uid.find(')') - if s >= 0 and e >= 0: - uid = uid[:s] + uid[e + 1:] - s = uid.find('<') - e = uid.find('>') - email = None - if s >= 0 and e >= 0: - email = uid[s + 1:e] - uid = uid[:s] + uid[e + 1:] - uid = uid.strip() - if not email and uid.find('@') >= 0: - email, uid = uid, email - return (uid, email) + (uid, mail) = email.utils.parseaddr(uid) + return (uid, mail) resultdict = {} @@ -85,6 +72,7 @@ def _get_canonical(key): def _add_to_result(key, newvalue): + logging.debug("adding %s: %s", key, newvalue) thekey = _get_canonical(key) if newvalue not in resultdict[thekey]: resultdict[thekey].append(newvalue) @@ -95,10 +83,10 @@ def process_keyrings(): file.""" for keyring in _get_keyrings(): logging.debug("get data from %s", keyring) - proc = subprocess.Popen(["gpg", "--no-default-keyring", + proc = subprocess.Popen(["gpg", "--no-options", "--no-default-keyring", "--no-expensive-trust-checks", "--keyring", keyring, "--list-keys", - "--with-colons", "--fingerprint"], + "--with-colons", "--fixed-list-mode", "--with-fingerprint", "--with-fingerprint"], stdout=subprocess.PIPE) fpr = None entry = None @@ -108,12 +96,13 @@ def process_keyrings(): uid = None if items[0] == 'pub': fpr = entry = None - lastpub = items[9].strip() + lastpub = items[4].strip() continue elif items[0] == 'fpr': fpr = items[9].strip() - uid = lastpub elif items[0] == 'uid': + if items[1] == 'r': + continue uid = items[9].strip() else: continue diff --git a/docs/source/conf.py b/docs/source/conf.py index 54103d2..f00d642 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -50,9 +50,9 @@ copyright = u'2009-2013, Jan Dittberner' # built documents. # # The short X.Y version. -version = '0.2.18.1' +version = '0.2.19' # The full version, including alpha/beta/rc tags. -release = '0.2.18' +release = '0.2.19' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/credits.rst b/docs/source/credits.rst index 74e2dd2..2744e27 100644 --- a/docs/source/credits.rst +++ b/docs/source/credits.rst @@ -8,6 +8,7 @@ Code * Jan Dittberner * Paul Wise + * Olivier Berger Translations ------------ diff --git a/setup.py b/setup.py index 2640725..1396e1e 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ except ImportError: setup( name='ddportfolioservice', - version='0.2.18.1', + version='0.2.19', description='service to create DDPortfolio URLs', long_description="""This is a service implementation that returns a set of personalized URLs as outlined in