1
2
3
4
5 """
6
7 ohloh
8 =====
9
10 This plugin uses http://rdfohloh.wikier.org/ to fetch DOAP for
11 projects listed on Ohlohh.
12
13
14 """
15
16 __docformat__ = 'epytext'
17
18
19 from doapfiend.utils import NotFoundError
20 from doapfiend.plugins.base import Plugin
21 from doapfiend.plugins.pkg_index import get_by_pkg_index
22
23
25
26 """Get DOAP from Ohloh package index"""
27
28
29 name = "oh"
30 enabled = False
31 enable_opt = name
32
34 '''Setup RDF/XML OutputPlugin class'''
35 super(OhlohPlugin, self).__init__()
36 self.options = None
37 self.query = None
38
40 """Add plugin's options to doapfiend's opt parser"""
41 search.add_option('--%s' % self.name,
42 action='store',
43 dest=self.enable_opt,
44 help='Get DOAP by its Ohloh project name or id #.',
45 metavar='PROJECT_NAME')
46 return parser, output, search
47
49 '''
50 Get Ohloh DOAP
51
52 @param proxy: Option HTTP proxy URL
53 @type proxy: string
54
55 @rtype: unicode
56 @returns: Single DOAP
57
58 '''
59 if hasattr(self.options, self.name):
60 self.query = getattr(self.options, self.name)
61
62 try:
63 return get_by_pkg_index(self.name, self.query, proxy)
64 except NotFoundError:
65 print "Not found: %s" % self.query
66