1
2
3
4
5 """
6 pypi
7 ====
8
9 Currently this plugin uses http://doapspace.org/ to fetch DOAP for PyPI
10 (The Python Package Index)
11
12 """
13
14 __docformat__ = 'epytext'
15
16
17 from doapfiend.utils import NotFoundError
18 from doapfiend.plugins.base import Plugin
19 from doapfiend.plugins.pkg_index import get_by_pkg_index
20
21
23
24 """Get DOAP from PyPI package index"""
25
26
27 name = 'py'
28 enabled = False
29 enable_opt = name
30
32 '''Setup RDF/XML OutputPlugin class'''
33 super(PyPIPlugin, self).__init__()
34 self.options = None
35 self.query = None
36
38 """Add plugin's options to doapfiend's opt parser"""
39 search.add_option('--%s' % self.name,
40 action='store',
41 dest=self.enable_opt,
42 help='Get DOAP by its PyPI project name.',
43 metavar='PROJECT_NAME')
44 return parser, output, search
45
47 '''
48 Get PyPI DOAP
49
50 @param proxy: URL of optional HTTP proxy
51 @type proxy: string
52
53 @rtype: unicode
54 @returns: Single DOAP
55
56 '''
57 if hasattr(self.options, self.name):
58 self.query = getattr(self.options, self.name)
59
60 try:
61 return get_by_pkg_index(self.name, self.query, proxy)
62 except NotFoundError:
63 print "Not found: %s" % self.query
64