initial implementation
This commit is contained in:
commit
d6f245a8d8
5 changed files with 157 additions and 0 deletions
1
ddportfolioservice/__init__.py
Normal file
1
ddportfolioservice/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
#
|
51
ddportfolioservice/ddportfolio.ini
Normal file
51
ddportfolioservice/ddportfolio.ini
Normal file
|
@ -0,0 +1,51 @@
|
|||
[overview]
|
||||
urls=ddpo,alladdresses
|
||||
ddpo.pattern=http://qa.debian.org/developer.php?login=%(email)s
|
||||
alladdresses.pattern=http://qa.debian.org/developer.php?login=%(name)s
|
||||
|
||||
[bugs]
|
||||
urls=received,reported,bugstats,usertags,searchall,wnpp
|
||||
received.pattern=http://bugs.debian.org/%(email)s
|
||||
reported.pattern=http://bugs.debian.org/from:%(email)s
|
||||
bugstats.pattern=http://asdfasdf.debian.net/~tar/bugstats/?%(email)s
|
||||
usertags.pattern=http://bugs.debian.org/cgi-bin/pkgreport.cgi?users=%(email)s
|
||||
searchall.pattern=http://merkel.debian.org/~don/cgi/search.cgi?phrase=%(name)s&search=search
|
||||
wnpp.pattern=http://qa.debian.org/developer.php?wnpp=%(email)s
|
||||
|
||||
[build]
|
||||
urls=buildd,igloo,svnbuildstat
|
||||
buildd.pattern=http://buildd.debian.org/pkg.cgi?maint=%(email)s
|
||||
igloo.pattern=http://oldpeople.debian.org/~igloo/status.php?email=%(email)s&thin=on
|
||||
svnbuildstat.pattern=http://svnbuildstat.debian.net/packages/list/%(email)s
|
||||
|
||||
[qa]
|
||||
urls=lintian,lintianfull,dehs
|
||||
lintian.pattern=http://lintian.debian.org/maintainer/%(email)s.html
|
||||
lintianfull.pattern=http://lintian.debian.org/full/%(email)s.html
|
||||
dehs.pattern=http://dehs.alioth.debian.org/report.php?login=%(email)s
|
||||
|
||||
[upload]
|
||||
urls=keylog
|
||||
keylog.pattern=http://merkel.debian.org/~enrico/keylog/%(gpgfp)s.html
|
||||
|
||||
[lists]
|
||||
urls=dolists,adolists,gmane
|
||||
dolists.pattern=http://lists.debian.org/cgi-bin/search?author=%(name)s&sort=date
|
||||
adolists.pattern=http://www.google.com/search?q=site%%3Alists.alioth.debian.org+%%22%(name)s%%22
|
||||
gmane.pattern=http://search.gmane.org/?email=%(name)s&group=gmane.linux.debian.*
|
||||
|
||||
[files]
|
||||
urls=people,alioth
|
||||
people.pattern=http://people.debian.org/~%(username)s/
|
||||
alioth.pattern=http://alioth.debian.org/~%(username)s/
|
||||
|
||||
[membership]
|
||||
urls=nm,db,alioth
|
||||
nm.pattern=https://nm.debian.org/nmstatus.php?email=%(email)s
|
||||
db.pattern=http://db.debian.org/search.cgi?uid=%(username)s&dosearch=Search
|
||||
alioth.pattern=http://alioth.debian.org/users/%(username)s/
|
||||
|
||||
[miscellaneous]
|
||||
urls=debtags,links
|
||||
debtags.pattern=http://debtags.alioth.debian.org/todo.html?maint=%(email)s
|
||||
links.pattern=http://www.google.com/search?hl=en&lr=&q=site%%3Adebian.org+%%22%(name)s%%22+-site%%3Anm.debian.org+-site%%3Alintian.debian.org+-site%%3Abugs.debian.org+-site%%3Alists.debian.org+-site%%3Apackages.debian.org+-site%%3Alists.alioth.debian.org+-site%%3Aftp.debian.org++-site%%3Apackages.qa.debian.org++-site%%3Aftp*.*.debian.org+-inurl%%3Adebian.org%%2Fdevel%%2Fpeople.+-inurl%%3Aindices%%2FMaintainers+-inurl%%3Adebian.org%%2Fdebian%%2Fproject++-inurl%%3A%%2Fdists%%2F&btnG=Search
|
68
ddportfolioservice/ddportfolio.py
Normal file
68
ddportfolioservice/ddportfolio.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
# -*- python -*-
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from paste.request import parse_formvars
|
||||
import pkg_resources
|
||||
import minjson
|
||||
from ConfigParser import ConfigParser
|
||||
from urllib import quote_plus
|
||||
|
||||
my_config = ConfigParser()
|
||||
my_config.readfp(pkg_resources.resource_stream(__name__, 'ddportfolio.ini'))
|
||||
|
||||
def build_urls(fields):
|
||||
result = {}
|
||||
qfields = dict([(key, quote_plus(fields[key])) for key in fields])
|
||||
for section in my_config.sections():
|
||||
if my_config.has_option(section, 'urls'):
|
||||
for url in my_config.get(section, 'urls').split(','):
|
||||
if my_config.has_option(section, url + '.pattern'):
|
||||
try:
|
||||
result[section + '.' + url] = \
|
||||
my_config.get(section, url + '.pattern',
|
||||
False, qfields)
|
||||
except Exception, e:
|
||||
print "unable to parse %s: %s" % (my_config.get(section, url + '.pattern', True), e)
|
||||
return result
|
||||
|
||||
def app(environ, start_response):
|
||||
fields = parse_formvars(environ)
|
||||
if environ['REQUEST_METHOD'] == 'POST':
|
||||
data = build_urls(fields)
|
||||
if ('mode' in fields and fields['mode'] == 'json'):
|
||||
start_response('200 OK', [('content-type', 'text/json')])
|
||||
return [minjson.write(data)]
|
||||
else:
|
||||
start_response('200 OK', [('content-type', 'text/html')])
|
||||
return ['''<html>
|
||||
<head><title>Debian Developer Portfolio</title></head>
|
||||
<body>
|
||||
<ul>
|
||||
<li>''', '</li><li>'.join(['%(key)s: <a href="%(url)s">%(url)s</a>' % {'key': key, 'url': data[key]} for key in data]), '</li></ul></body></html>']
|
||||
else:
|
||||
start_response('200 OK', [('content-type', 'text/html')])
|
||||
return ['''<html>
|
||||
<head>
|
||||
<title>Debian Developer Portfolio</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post">
|
||||
<fieldset id="ddportfolio">
|
||||
<legend>Debian Developer Portfolio</legend>
|
||||
<label for="name">Name:</label><br />
|
||||
<input type="text" name="name" /><br />
|
||||
<label for="email">E-Mail:</label><br />
|
||||
<input type="text" name="email" /><br />
|
||||
<label for="gpgfp">GPG-Fingerprint:</label><br />
|
||||
<input type="text" name="gpgfp" /><br />
|
||||
<label for="username">User name:</label><br />
|
||||
<input type="text" name="username" /><br />
|
||||
<input type="submit" value="Build DD Portfolio URLs" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>''']
|
||||
|
||||
if __name__ == '__main__':
|
||||
from paste import httpserver
|
||||
httpserver.serve(app, host='127.0.0.1', port='8080')
|
3
setup.cfg
Normal file
3
setup.cfg
Normal file
|
@ -0,0 +1,3 @@
|
|||
[egg_info]
|
||||
tag_build = dev
|
||||
tag_svn_revision = true
|
34
setup.py
Normal file
34
setup.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from setuptools import setup, find_packages
|
||||
import sys, os
|
||||
|
||||
version = '0.1'
|
||||
|
||||
setup(name='ddportfolioservice',
|
||||
version=version,
|
||||
description="service to create DDPortfolio URLs",
|
||||
long_description="""This is a service implementation that
|
||||
returns a set of personalized URLs as outlined in
|
||||
http://wiki.debian.org/DDPortfolio. It takes the Debian developers
|
||||
full name and email address as input and returns a JSON formatted
|
||||
array of URLs.""",
|
||||
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=['Development Status :: 3 - Alpha',
|
||||
'Environment :: Web Environment',
|
||||
'License :: DFSG approved',
|
||||
'License :: OSI approved :: ' .
|
||||
'GNU Affero General Public License v3',
|
||||
'Programming Language :: Python'],
|
||||
keywords='Debian service JSON',
|
||||
author='Jan Dittberner',
|
||||
author_email='jan@dittberner.info',
|
||||
url='http://debian-stuff.dittberner.info/ddportfolioservice/',
|
||||
license='AGPLv3',
|
||||
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
# -*- Extra requirements: -*-
|
||||
'PasteDeploy',
|
||||
'python-json'
|
||||
],
|
||||
)
|
Loading…
Reference in a new issue