本文整理汇总了Python中translate.Translator.frtoen方法的典型用法代码示例。如果您正苦于以下问题:Python Translator.frtoen方法的具体用法?Python Translator.frtoen怎么用?Python Translator.frtoen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类translate.Translator
的用法示例。
在下文中一共展示了Translator.frtoen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BotnetJabberClient
# 需要导入模块: from translate import Translator [as 别名]
# 或者: from translate.Translator import frtoen [as 别名]
class BotnetJabberClient(GTalkBot):
BOT_USER = '[email protected]'
BOT_PASS = 'pycon123'
def __init__(self):
self.eliza = eliza()
super(BotnetJabberClient,self).__init__(self.BOT_USER, self.BOT_PASS)
self.geoPlanet = YahooGeoPlanetSearch()
self.yahooWeather = YahooWeatherSearch()
self.pyconIreland = PyconIreland()
self.translator = Translator()
@botcommand
def weather(self, mess, args):
"""Returns the forecasts for any place. Usage: weather [City Name]"""
try:
woeid = self.geoPlanet.place_search(args).woeid()
result = self.format_weather_result(self.yahooWeather.forecast(woeid))
return result.encode("utf-8")
except InvalidSearchError:
return "Invalid Search, plz try again"
except Exception:
return "Unknow error... sorry about that"
@botcommand
def currency(self, mess, args):
"""Returns updated information about Dollar currency"""
return finance.exchange_rate()
@botcommand
def talk(self, mess, args):
"Retrieves information about talks at Pycon Ireland 2010. Search for the authors name or the talks name"
return self.pyconIreland.find_talk(args)
@botcommand
def speaker(self, mess, args):
"""Returns Information about any of the speakers at Pycon Ireland 2010"""
return self.pyconIreland.find_speaker(args)
def unknown_command( self, mess, cmd, args):
"""Putting some Mojo here to make the bot answer as Eliza when wrong command is given"""
return self.eliza.respond(mess.getBody())
def format_weather_result(self, result):
model_header = "{0}\n {1} C - {2} \n Forecasts\n"
model_forecasts = "{0} -> {1} with max {2} C | min {3} C\n"
forecast_result = model_header.format(result['title'], result['current_temp'], result['current_condition'])
for forecast in result['forecasts']:
forecast_result += model_forecasts.format(forecast['date'], forecast['condition'], forecast['high'], forecast['low'])
return forecast_result
@botcommand
def entofr(self, mess, args):
"""Returns the French translation of an English word. Usage: entofr [Word in English]"""
return self.translator.entofr(args)
@botcommand
def frtoen(self, mess, args):
"""Returns the English translation of a French word. Usage: frtoen [Word in French]"""
return self.translator.frtoen(args)