Exemplo n.º 1
0
 def crawl_moksha_topics(self, entry_point='moksha.widget'):
     """ Iterate over all moksha widgets looking for topics """
     topics = defaultdict(list)
     for entry in pkg_resources.iter_entry_points(entry_point):
         entry_class = entry.load()
         for topic in listify(getattr(entry_class, 'topic', [])):
             topics[to_unicode(topic)].append(entry_class)
         for topic in listify(getattr(entry_class, 'topics', [])):
             topics[to_unicode(topic)].append(entry_class)
     return topics
Exemplo n.º 2
0
 def crawl_moksha_topics(self, entry_point='moksha.widget'):
     """ Iterate over all moksha widgets looking for topics """
     topics = defaultdict(list)
     for entry in pkg_resources.iter_entry_points(entry_point):
         entry_class = entry.load()
         for topic in listify(getattr(entry_class, 'topic', [])):
             topics[to_unicode(topic)].append(entry_class)
         for topic in listify(getattr(entry_class, 'topics', [])):
             topics[to_unicode(topic)].append(entry_class)
     return topics
Exemplo n.º 3
0
 def get_entry(self, key, **kw):
     if '::' in key:
         url, title = key.split('::')
         for entry in moksha.feed_storage[url][1]['entries']:
             content = entry.get('content', entry.get('summary'))
             if isinstance(content, list):
                 if isinstance(content[0], dict) and \
                    content[0].has_key('value'):
                     content = content[0]['value']
             content = """
                 <blockquote><h3><a href="%s">%s</a></h3><br/>%s</blockquote>
             """ % (entry.get('link', url), entry['title'], content)
             if entry['title'].replace(' ', '') == to_unicode(title):
                 return content
         raise Exception("Cannot find entry by title: %s" % title)
     else:
         raise Exception("Invalid entry key: %r" % key)
Exemplo n.º 4
0
 def get_entry(self, message, **kw):
     key = message['key']
     if '::' in key:
         url, title = key.split('::')
         for entry in self.feed_storage[url][1]['entries']:
             content = entry.get('content', entry.get('summary'))
             if isinstance(content, list):
                 if isinstance(content[0], dict) and \
                    content[0].has_key('value'):
                     content = content[0]['value']
             content = """
                 <blockquote><h3><a href="%s">%s</a></h3><br/>%s</blockquote>
             """ % (entry.get('link', url), entry['title'], content)
             if entry['title'].replace(' ', '') == to_unicode(title):
                 self.send_message(message['topic'], {
                         'content': content,
                         'action': 'get_entry'
                         })
                 return
         raise Exception("Cannot find entry by title: %s" % title)
     else:
         raise Exception("Invalid entry key: %r" % key)