def test_two_way(self):
        with self.subTest("should get same result when translated both ways"):
            trad = '皇后與國王在後面共同候車'
            result = to_traditional(to_simplified(trad))

            self.assertEqual(trad, result)

            simp = '皇后与国王在后面共同候车后'
            result = to_simplified(to_traditional(simp))

            self.assertEqual(simp, result)
Пример #2
0
 async def Sortie(self, ctx, *args):
     if ctx.message.author.id == jdata['owner']:
         args = str(args).replace(",", "")
         args = args.replace("\'", "")
         args = args.replace("(", "")
         args = args.replace(")", "")
         offset = int(args)
         if offset > 0:
             while (True):
                 count = 1
                 raw = requests.get(
                     'https://api.warframestat.us/pc/zh/sortie',
                     headers={'Accept-Language': 'tc'})
                 text = raw.text
                 text = chinese_converter.to_traditional(text)
                 data = json.loads(text)
                 msg = f"```\n突擊剩餘時間:{data['eta']}\n{data['boss']}的部隊,{data['faction']}陣營```"
                 for missions in data['variants']:
                     node = missions['node']
                     missionType = missions['missionType']
                     modifier = missions['modifier']
                     msg += f'```突擊{count}:\n節點:{node} 等級{35+15*count}-{40+20*count}\n任務:{missionType}\n狀態:{modifier}```'
                     count += 1
                 await ctx.send(msg)
                 expiry = data['expiry']
                 timeLeft = datetime.strptime(expiry, '%Y-%m-%dT%X.000Z')
                 now = datetime.now()
                 timeLeft = timeLeft - now
                 await asyncio.sleep(timeLeft.seconds + offset)
     else:
         await ctx.send("權限不足")
Пример #3
0
 async def arbitration(self, ctx, *args):
     if ctx.message.author.id == jdata['owner']:
         args = str(args).replace(",", "")
         args = args.replace("\'", "")
         args = args.replace("(", "")
         args = args.replace(")", "")
         offset = int(args)
         if offset > 0:
             while (True):
                 raw = requests.get(
                     "https://api.warframestat.us/pc/tc/arbitration",
                     headers={'Accept-Language': 'zh'})
                 text = raw.text
                 text = chinese_converter.to_traditional(text)
                 data = json.loads(text)
                 expiry = data['expiry']
                 timeLeft = datetime.strptime(expiry, '%Y-%m-%dT%X.000Z')
                 now = datetime.now()
                 timeLeft = timeLeft - now
                 minutes = int(
                     (timeLeft.seconds - timeLeft.seconds % 60) / 60)
                 seconds = timeLeft.seconds % 60
                 await ctx.send(
                     f"```\n當前仲裁任務(API並不穩定,僅供參考):\n任務:{data['type']}\n節點:{data['node']}\n敵人:{data['enemy']}\n剩餘時間:{minutes}分鐘{seconds}秒```"
                 )
                 await asyncio.sleep(timeLeft.seconds + offset)
     else:
         await ctx.send("權限不足")
 async def baroManual(self, ctx):
     url = requests.get("https://api.warframestat.us/pc/tc/voidTrader",
                        headers={
                            'Accept-Language': 'zh',
                            'Cache-Control': 'no-cache'
                        })
     html = json.loads(url.text)
     if html['active'] == True:
         message = "```"
         location = html['location']
         location = chinese_converter.to_traditional(location)
         stay = html['endString']
         stay = stay.replace("d", "天")
         stay = stay.replace("h", "小時")
         stay = stay.replace("m", "分鐘")
         stay = stay.replace("s", "秒")
         await ctx.send(f"Baro Ki'Teer 已經到達{location},停留時間為{stay}\t帶來的商品如下:"
                        )
         for items in html['inventory']:
             item = items['item']
             item = item.lower()
             item = item.replace("\'", "")
             count = 0
             name = ''
             for words in item.split():
                 if count != 0:
                     word = words.capitalize()
                     name += word
                 elif count == 0:
                     name += words
                 count += 1
             name = Dict.get(name, name)
             ducats = items['ducats']
             credits = items['credits']
             message += f"物品:{name}\n杜卡德金幣:{ducats}\t現金:{credits}\n"
         message += "```"
         await ctx.send(message)
     if html['active'] == False:
         location = html['location']
         location = chinese_converter.to_traditional(location)
         arrive = html['endString']
         arrive = arrive.replace("d", "天")
         arrive = arrive.replace("h", "小時")
         arrive = arrive.replace("m", "分鐘")
         arrive = arrive.replace("s", "秒")
         await ctx.send(f"Baro Ki' Teer會在{arrive}後抵達{location}")
Пример #5
0
 async def arbitration(self,ctx):
   raw = requests.get("https://api.warframestat.us/pc/tc/arbitration",headers={'Accept-Language':'zh'})
   text = raw.text
   text = chinese_converter.to_traditional(text)
   data = json.loads(text)
   expiry = data['expiry']
   timeLeft = datetime.strptime(expiry,'%Y-%m-%dT%X.000Z')
   now = datetime.now()
   timeLeft = timeLeft-now
   minutes = int((timeLeft.seconds - timeLeft.seconds%60)/60)
   seconds = timeLeft.seconds%60
   await ctx.send(f"```\n當前仲裁任務(API並不穩定,僅供參考):\n任務:{data['type']}\n節點:{data['node']}\n敵人:{data['enemy']}\n剩餘時間:{minutes}分鐘{seconds}秒```")
Пример #6
0
def book_to_traditional(book: epub.EpubBook) -> epub.EpubBook:
    try:
        title = book.get_metadata('DC', 'title')[0][0]
        book.set_unique_metadata('DC', 'title',
                                 converter.to_traditional(title))
    except IndexError:
        pass

    for item in book.get_items():
        if item.get_type() == ebooklib.ITEM_DOCUMENT:
            doc = etree.fromstring(item.get_content())
            for t in doc.xpath('//text()'):
                p = t.getparent()
                if p.text:
                    p.text = converter.to_traditional(p.text)
                if p.tail:
                    p.tail = converter.to_traditional(p.tail)

            item.set_content(etree.tostring(doc, pretty_print=True))

    return book
Пример #7
0
 async def sortie(self,ctx):
   count = 1
   raw = requests.get('https://api.warframestat.us/pc/zh/sortie',headers={'Accept-Language':'tc'})
   text = raw.text
   text = chinese_converter.to_traditional(text)
   data = json.loads(text)
   await ctx.send(f"```\n突擊剩餘時間:{data['eta']}\n{data['boss']}的部隊,{data['faction']}陣營```")
   for missions in data['variants']:
     node = missions['node']
     missionType= missions['missionType']
     modifier = missions['modifier']
     await ctx.send(f'```突擊{count}:\n節點:{node} 等級{35+15*count}-{40+20*count}\n任務:{missionType}\n狀態:{modifier}```')
     count += 1
    def test_other_language(self):
        text = "this is a book."

        with self.subTest("should not change text in other languages"):
            self.assertEqual(text, to_simplified(text))
            self.assertEqual(text, to_traditional(text))
    def test_to_traditional(self):
        result = to_traditional('皇后与国王在后面共同候车面食后')

        self.assertEqual(result, '皇后與國王在後面共同候車麵食後')