<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from django import template <EOL> from sentry . plugins import Annotation , plugins <EOL> from sentry . utils . safe import safe_execute <EOL> register = template . Library ( ) <EOL> @ register . filter <EOL> def get_actions ( group , request ) : <EOL> project = group . project <EOL> action_list = [ ] <EOL> for plugin in plugins . for_project ( project , version = <NUM_LIT:1> ) : <EOL> results = safe_execute ( plugin . actions , request , group , action_list ) <EOL> if not results : <EOL> continue <EOL> action_list = results <EOL> for plugin in plugins . for_project ( project , version = <NUM_LIT:2> ) : <EOL> for action in ( safe_execute ( plugin . get_actions , request , group ) or ( ) ) : <EOL> action_list . append ( action ) <EOL> return [ ( a [ <NUM_LIT:0> ] , a [ <NUM_LIT:1> ] , request . path == a [ <NUM_LIT:1> ] ) for a in action_list ] <EOL> @ register . filter <EOL> def get_panels ( group , request ) : <EOL> project = group . project <EOL> panel_list = [ ] <EOL> for plugin in plugins . for_project ( project ) : <EOL> results = safe_execute ( plugin . panels , request , group , panel_list ) <EOL> if not results : <EOL> continue <EOL> panel_list = results <EOL> return [ ( p [ <NUM_LIT:0> ] , p [ <NUM_LIT:1> ] , request . path == p [ <NUM_LIT:1> ] ) for p in panel_list ] <EOL> @ register . filter <EOL> def get_widgets ( group , request ) : <EOL> project = group . project <EOL> for plugin in plugins . for_project ( project ) : <EOL> resp = safe_execute ( plugin . widget , request , group ) <EOL> if resp : <EOL> yield resp . render ( request ) <EOL> @ register . filter <EOL> def get_legacy_annotations ( group , request = None ) : <EOL> project = group . project <EOL> annotation_list = [ ] <EOL> for plugin in plugins . for_project ( project , version = <NUM_LIT:1> ) : <EOL> results = safe_execute ( plugin . tags , request , group , annotation_list ) <EOL> if not results : <EOL> continue <EOL> annotation_list = results <EOL> return annotation_list <EOL> @ register . filter <EOL> def get_annotations ( group , request = None ) : <EOL> project = group . project <EOL> annotation_list = [ ] <EOL> for plugin in plugins . for_project ( project , version = <NUM_LIT:2> ) : <EOL> for value in ( safe_execute ( plugin . get_annotations , group = group ) or ( ) ) : <EOL> annotation = safe_execute ( Annotation , ** value ) <EOL> if annotation : <EOL> annotation_list . append ( annotation ) <EOL> return annotation_list <EOL> @ register . simple_tag <EOL> def handle_before_events ( request , event_list ) : <EOL> if not event_list : <EOL> return '<STR_LIT>' <EOL> if not hasattr ( event_list , '<STR_LIT>' ) : <EOL> project = event_list . project <EOL> event_list = [ event_list ] <EOL> else : <EOL> projects = set ( e . project for e in event_list ) <EOL> if len ( projects ) == <NUM_LIT:1> : <EOL> project = projects . pop ( ) <EOL> else : <EOL> project = None <EOL> for plugin in plugins . for_project ( project ) : <EOL> safe_execute ( plugin . before_events , request , event_list ) <EOL> return '<STR_LIT>' <EOL> @ register . filter <EOL> def get_plugins ( project ) : <EOL> results = [ ] <EOL> for plugin in plugins . for_project ( project , version = None ) : <EOL> if plugin . has_project_conf ( ) : <EOL> results . append ( plugin ) <EOL> return results <EOL> @ register . filter <EOL> def get_plugins_with_status ( project ) : <EOL> return [ <EOL> ( plugin , safe_execute ( plugin . is_enabled , project ) ) <EOL> for plugin in plugins . configurable_for_project ( project , version = None ) <EOL> ] </s>
