<s> import sys , re <EOL> import requests <EOL> import json <EOL> from JustReleaseNotes . issuers import BaseIssues <EOL> class JiraIssues ( BaseIssues . BaseIssues ) : <EOL> __restSearchUrl = None <EOL> __jiraAuthorization = None <EOL> __cache = { } <EOL> def __init__ ( self , conf ) : <EOL> self . __restSearchUrl = conf [ "<STR_LIT>" ] <EOL> self . __jiraAuthorization = conf [ "<STR_LIT>" ] <EOL> self . __conf = conf <EOL> self . ticketRegex = '<STR_LIT>' <EOL> if "<STR_LIT>" in conf : <EOL> self . ticketRegex = conf [ "<STR_LIT>" ] <EOL> def __log ( self , message ) : <EOL> print ( "<STR_LIT>" + message ) <EOL> sys . stdout . flush ( ) <EOL> def __readJsonInfo ( self , ticket ) : <EOL> if ticket in self . __cache : <EOL> self . __log ( "<STR_LIT>" + ticket ) <EOL> return self . __cache [ ticket ] <EOL> uri = "<STR_LIT>" . format ( self . __restSearchUrl , ticket ) <EOL> headers = { '<STR_LIT>' : self . __jiraAuthorization } <EOL> self . __log ( "<STR_LIT>" + ticket ) <EOL> r = requests . get ( uri , headers = headers , verify = False ) <EOL> data = json . loads ( r . text ) <EOL> if "<STR_LIT>" in data : <EOL> self . __log ( "<STR_LIT>" + "<STR_LIT:U+002C>" . join ( data [ "<STR_LIT>" ] ) ) <EOL> self . __cache [ ticket ] = data <EOL> return data <EOL> def getTicketInfo ( self , ticket ) : <EOL> data = self . __readJsonInfo ( ticket ) <EOL> embedded_links = { } <EOL> title = "<STR_LIT>" <EOL> ret = { "<STR_LIT>" : "<STR_LIT>" . format ( self . __conf [ "<STR_LIT>" ] , ticket ) , <EOL> "<STR_LIT>" : ticket , <EOL> "<STR_LIT:title>" : title } <EOL> if "<STR_LIT>" in data . keys ( ) : <EOL> title = data [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> ret [ "<STR_LIT:title>" ] = title <EOL> for ticket in self . extractTicketsFromMessage ( title ) : <EOL> embedded_links [ ticket ] = "<STR_LIT>" . format ( self . __conf [ "<STR_LIT>" ] , ticket ) <EOL> ret [ "<STR_LIT>" ] = self . __fieldIcon ( data [ "<STR_LIT>" ] [ "<STR_LIT:status>" ] ) <EOL> ret [ "<STR_LIT>" ] = self . __fieldIcon ( data [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> ret [ "<STR_LIT>" ] = self . __fieldIcon ( data [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> ret [ "<STR_LIT>" ] = embedded_links <EOL> ret [ "<STR_LIT>" ] = data [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> else : <EOL> return None <EOL> return ret <EOL> def __fieldIcon ( self , f ) : <EOL> if "<STR_LIT>" in self . __conf : <EOL> parts = f [ "<STR_LIT>" ] . split ( "<STR_LIT:/>" ) <EOL> return '<STR_LIT>' . format ( self . __conf [ "<STR_LIT>" ] , parts [ len ( parts ) - <NUM_LIT:1> ] , f [ "<STR_LIT:name>" ] ) <EOL> else : <EOL> return f [ "<STR_LIT>" ] </s>
