diff --git a/bug/__pycache__/bugtracker.cpython-38.pyc b/bug/__pycache__/bugtracker.cpython-38.pyc index 22f50256..bddbfab3 100644 Binary files a/bug/__pycache__/bugtracker.cpython-38.pyc and b/bug/__pycache__/bugtracker.cpython-38.pyc differ diff --git a/bug/bugtracker.py b/bug/bugtracker.py index 25ef0324..4ec81351 100644 --- a/bug/bugtracker.py +++ b/bug/bugtracker.py @@ -28,46 +28,24 @@ def bug(pagename): json_text = requests.get(url_json,timeout=10) file = json.loads(json_text.text) Versions = file['fields']['versions'] + name = [] for item in Versions[:]: - name = item['name']+"|" - y = open('bug_cache_text.txt',mode='a',encoding='utf-8') - y.write(name) - y.close() - z = open('bug_cache_text.txt',mode='r',encoding='utf-8') - j = z.read() - m = j.strip(string.punctuation) - if m.split('|')[0] == m.split('|')[-1]: - Version = "Version: "+m.split('|')[0] + name.append(item['name']) + if name[0] == name[-1]: + Version = "Version: "+name[0] else: - Version = "Versions: "+m.split('|')[0]+"~"+m.split('|')[-1] + Version = "Versions: "+name[0]+"~"+name[-1] try: Priority = "Mojang Priority: "+file['fields']['customfield_12200']['value'] return(Title+'\n'+Type+'\n'+Project+'\n'+TStatus+'\n'+Priority+'\n'+Resolution+'\n'+Version+'\n'+Link) - z.close() - os.remove('bug_cache_text.txt') except Exception: return (Title+'\n'+Type+'\n'+Project+'\n'+TStatus+'\n'+Resolution+'\n'+Version+'\n'+Link) except Exception: try: - respose_str.encoding = 'utf-8' - root = ElementTree.XML(respose_str.text) - for node in root.iter("channel"): - for node in root.iter("item"): - Title = node.find("title").text - Type = "Type: " + node.find("type").text - TStatus = "Status: " + node.find("status").text - Resolution = "Resolution: " + node.find("resolution").text - Priority = "Priority: " + node.find("priority").text - Link = node.find("link").text - return (Title+'\n'+Type+'\n'+TStatus+'\n'+Priority+'\n'+Resolution+'\n'+Link) + return (Title+'\n'+Type+'\n'+TStatus+'\n'+Priority+'\n'+Resolution+'\n'+Link) except Exception: try: - respose_str.encoding = 'utf-8' - root = ElementTree.XML(respose_str.text) - for node in root.iter("channel"): - for node in root.iter("item"): - Link = node.find("link").text - return(Link) + return(Link) except Exception as e: return ("发生错误:"+str(e)+".") except Exception as e: diff --git a/bug/bugtrackerbc.py b/bug/bugtrackerbc.py index df4bceb6..f1d505ac 100644 --- a/bug/bugtrackerbc.py +++ b/bug/bugtrackerbc.py @@ -32,10 +32,10 @@ async def bugcb(pagename): for node in root.iter("item"): Title = node.find("title").text q = node.find("title").text - Type = "Type: " + node.find("type").text - Project = "Project: " + node.find("project").text - TStatus = "Status: " + node.find("status").text - Resolution = "Resolution: " + node.find("resolution").text + Type = "类型:" + node.find("type").text + Project = "项目:" + node.find("project").text + TStatus = "进度:" + node.find("status").text + Resolution = "状态:" + node.find("resolution").text Link = node.find("link").text sign = appid + q + str(salt) + secretKey sign = hashlib.md5(sign.encode()).hexdigest() @@ -44,14 +44,9 @@ async def bugcb(pagename): json_text = requests.get(url_json,timeout=10) file = json.loads(json_text.text) Versions = file['fields']['versions'] + name = [] for item in Versions[:]: - name = item['name']+"|" - y = open('bug_cache_text.txt',mode='a',encoding='utf-8') - y.write(name) - y.close() - z = open('bug_cache_text.txt',mode='r',encoding='utf-8') - j = z.read() - m = j.strip(string.punctuation) + name.append(item['name']) httpClient = http.client.HTTPConnection('api.fanyi.baidu.com') httpClient.request('GET', myurl) response = httpClient.getresponse() @@ -59,10 +54,10 @@ async def bugcb(pagename): result = json.loads(result_all) for item in result['trans_result']: dst=item['dst'] - if m.split('|')[0] == m.split('|')[-1]: - Version = "Version: "+m.split('|')[0] - else: - Version = "Versions: "+m.split('|')[0]+"~"+m.split('|')[-1] + if name[0] == name[-1]: + Version = "Version: "+name[0] + else: + Version = "Versions: "+name[0]+"~"+name[-1] try: Priority = "Mojang Priority: "+file['fields']['customfield_12200']['value'] return(Title+'\n'+dst+'\n'+Type+'\n'+Project+'\n'+TStatus+'\n'+Priority+'\n'+Resolution+'\n'+Version+'\n'+Link+'\n'+'由百度翻译提供支持。') @@ -78,10 +73,10 @@ async def bugcb(pagename): for node in root.iter("item"): Title = node.find("title").text q = node.find("title").text - Type = "Type: " + node.find("type").text - TStatus = "Status: " + node.find("status").text - Resolution = "Resolution: " + node.find("resolution").text - Priority = "Priority: " + node.find("priority").text + Type = "类型:" + node.find("type").text + TStatus = "项目:" + node.find("status").text + Resolution = "进度:" + node.find("resolution").text + Priority = "Mojang优先级:" + node.find("priority").text Link = node.find("link").text sign = appid + q + str(salt) + secretKey sign = hashlib.md5(sign.encode()).hexdigest() diff --git a/bug/bugtrackergc.py b/bug/bugtrackergc.py index c607900c..4670e6d8 100644 --- a/bug/bugtrackergc.py +++ b/bug/bugtrackergc.py @@ -31,18 +31,13 @@ async def buggc(pagename): json_text = requests.get(url_json,timeout=10) file = json.loads(json_text.text) Versions = file['fields']['versions'] + name = [] for item in Versions[:]: - name = item['name']+"|" - y = open('bug_cache_text.txt',mode='a',encoding='utf-8') - y.write(name) - y.close() - z = open('bug_cache_text.txt',mode='r',encoding='utf-8') - j = z.read() - m = j.strip(string.punctuation) - if m.split('|')[0] == m.split('|')[-1]: - Version = "版本:"+m.split('|')[0] - else: - Version = "版本:"+m.split('|')[0]+"~"+m.split('|')[-1] + name.append(item['name']) + if name[0] == name[-1]: + Version = "Version: "+name[0] + else: + Version = "Versions: "+name[0]+"~"+name[-1] try: Priority = "Mojang优先级:"+tr.translate(file['fields']['customfield_12200']['value'],dest='zh-cn').text return(Title+'\n'+Titleg+'\n'+Type+'\n'+Project+'\n'+TStatus+'\n'+Priority+'\n'+Resolution+'\n'+Version+'\n'+Link+'\n'+"由Google翻译提供支持。")