Package doapfiend :: Package plugins :: Module freshmeat
[hide private]
[frames] | no frames]

Source Code for Module doapfiend.plugins.freshmeat

 1  #!/usr/bin/env python 
 2   
 3  # pylint: disable-msg=W0221,R0201 
 4   
 5  """ 
 6   
 7  freshmeat 
 8  ========= 
 9   
10  Currently this plugin uses http://doapspace.org/ to fetch DOAP for Freshmeat 
11   
12   
13  """ 
14   
15  __docformat__ = 'epytext' 
16   
17   
18  from doapfiend.utils import NotFoundError 
19  from doapfiend.plugins.base import Plugin 
20  from doapfiend.plugins.pkg_index import get_by_pkg_index 
21   
22   
23 -class FreshmeatPlugin(Plugin):
24 25 """Get DOAP from Freshmeat package index""" 26 27 #This will be the opt_parser option (--fm) in the output group 28 name = "freshmeat" 29 prefix = 'fm' 30 enabled = False 31 enable_opt = name 32
33 - def __init__(self):
34 '''Setup RDF/XML OutputPlugin class''' 35 super(FreshmeatPlugin, self).__init__() 36 self.options = None 37 self.query = None
38
39 - def add_options(self, parser, output, search):
40 """Add plugin's options to doapfiend's opt parser""" 41 search.add_option('-f', '--%s' % self.name, 42 action='store', 43 dest=self.enable_opt, 44 help='Get DOAP by its Freshmeat project name.', 45 metavar='PROJECT_NAME') 46 return parser, output, search
47
48 - def search(self, proxy=None):
49 ''' 50 Get Freshmeat DOAP 51 52 @param proxy: URL of optional HTTP proxy 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 #Else self.query was set directly, someone not using the CLI 62 try: 63 return get_by_pkg_index(self.prefix, self.query, proxy) 64 except NotFoundError: 65 print "Not found: %s" % self.options.freshmeat
66