<s> import logging <EOL> from cafe . resources . launchpad . config import LaunchpadTrackerConfig <EOL> from lplight . client import LaunchpadClient <EOL> class LaunchpadTracker ( object ) : <EOL> @ classmethod <EOL> def is_bug_open ( cls , bug_id ) : <EOL> """<STR_LIT>""" <EOL> config = LaunchpadTrackerConfig ( ) <EOL> log = logging . getLogger ( '<STR_LIT>' ) <EOL> launchpad = LaunchpadClient ( ) <EOL> if config . closed_tags is not None : <EOL> bug_resp = launchpad . get_bug_by_id ( bug_id ) <EOL> cls . _log_if_not_found ( log , bug_resp , bug_id ) <EOL> tags = bug_resp . model . tags if bug_resp . model else None <EOL> if cls . _bug_tags_are_open ( tags , config ) : <EOL> return True <EOL> if config . use_status : <EOL> tasks_resp = launchpad . get_bug_tasks ( bug_id ) <EOL> cls . _log_if_not_found ( log , tasks_resp , bug_id ) <EOL> tasks = tasks_resp . model or [ ] <EOL> if cls . _bug_status_is_open ( tasks , config ) : <EOL> return True <EOL> log . info ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( config . project ) ) <EOL> return False <EOL> @ classmethod <EOL> def _log_if_not_found ( cls , log , resp , bug_id ) : <EOL> if resp . status_code == <NUM_LIT> : <EOL> log . info ( '<STR_LIT>' . format ( bug_id ) ) <EOL> @ classmethod <EOL> def _bug_status_is_open ( cls , tasks , config ) : <EOL> for bug_task in tasks : <EOL> if bug_task . bug_target_name == config . project : <EOL> return bug_task . status not in ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return False <EOL> @ classmethod <EOL> def _bug_tags_are_open ( cls , tags , config ) : <EOL> if tags is None : <EOL> return False <EOL> tag_set = set ( x . lower ( ) for x in tags ) <EOL> closed_tags = set ( x . lower ( ) for x in config . closed_tags ) <EOL> matches = tag_set . intersection ( closed_tags ) <EOL> return not bool ( matches ) </s>
