def get(self): query = self.get_argument('q', default='pairs') if query == 'pairs': responseData = [] for pair in self.pairs: (l1, l2) = pair.split('-') responseData.append({ 'sourceLanguage': l1, 'targetLanguage': l2 }) if self.get_arguments('include_deprecated_codes'): responseData.append({ 'sourceLanguage': toAlpha2Code(l1), 'targetLanguage': toAlpha2Code(l2) }) self.sendResponse({ 'responseData': responseData, 'responseDetails': None, 'responseStatus': 200 }) elif query == 'analyzers' or query == 'analysers': self.sendResponse({ pair: modename for (pair, (path, modename)) in self.analyzers.items() }) elif query == 'generators': self.sendResponse({ pair: modename for (pair, (path, modename)) in self.generators.items() }) elif query == 'taggers' or query == 'disambiguators': self.sendResponse({ pair: modename for (pair, (path, modename)) in self.taggers.items() }) else: self.send_error( 400, explanation= 'Expecting q argument to be one of analysers, generators, disambiguators or pairs' )
def get(self): query = self.get_argument('q', default='pairs') if query == 'pairs': responseData = [] for pair in self.pairs: (l1, l2) = pair.split('-') responseData.append({'sourceLanguage': l1, 'targetLanguage': l2}) if self.get_arguments('include_deprecated_codes'): responseData.append({'sourceLanguage': toAlpha2Code(l1), 'targetLanguage': toAlpha2Code(l2)}) self.sendResponse({'responseData': responseData, 'responseDetails': None, 'responseStatus': 200}) elif query == 'analyzers' or query == 'analysers': self.sendResponse({pair: modename for (pair, (path, modename)) in self.analyzers.items()}) elif query == 'generators': self.sendResponse({pair: modename for (pair, (path, modename)) in self.generators.items()}) elif query == 'taggers' or query == 'disambiguators': self.sendResponse({pair: modename for (pair, (path, modename)) in self.taggers.items()}) else: self.send_error(400, explanation='Expecting q argument to be one of analysers, generators, disambiguators or pairs')
def convertISOCode(code): return (code, toAlpha2Code(code))