def get(self): to_translate = self.get_argument('q') try: l1, l2 = map(to_alpha3_code, self.get_argument('langpair').split('|')) except ValueError: self.send_error( 400, explanation='That pair is invalid, use e.g. eng|spa') return mode_path = self.pairs['%s-%s' % (l1, l2)] try: _, commands = parse_mode_file(mode_path) except Exception: self.send_error(500) return res = yield translate_pipeline(to_translate, commands) if self.get_status() != 200: self.send_error(self.get_status()) return output, pipeline = res self.send_response({ 'responseData': { 'output': output, 'pipeline': pipeline }, 'responseDetails': None, 'responseStatus': 200, })
def get_pipe_cmds(self, l1, l2): if (l1, l2) not in self.pipeline_cmds: mode_path = self.pairs['%s-%s' % (l1, l2)] self.pipeline_cmds[(l1, l2)] = parse_mode_file(mode_path) return self.pipeline_cmds[(l1, l2)]
def get_pipe_cmds(self, l1, l2): if (l1, l2) not in self.pipeline_cmds: mode_path = self.pairs['%s-%s' % (l1, l2)] self.pipeline_cmds[(l1, l2)] = parse_mode_file(mode_path) return self.pipeline_cmds[(l1, l2)]