def __readAvailableNations(self, xmlCtx, root): names = [] indices = nations.INDICES for _, section in _xml.getChildren(xmlCtx, root, 'available-nations'): name = section.asString if name not in indices: _xml.raiseWrongXml(xmlCtx, 'available-nations', 'Nation {0:>s} not found'.format(name)) if name not in nations.AVAILABLE_NAMES: LOG_ERROR( 'Nation ignored, it not found in nations.AVAILABLE_NAMES', name) continue names.append(name) names = sorted( names, cmp=lambda item, other: cmp(GUI_NATIONS_ORDER_INDEX.get(item), GUI_NATIONS_ORDER_INDEX.get(other))) return names
def __readAvailableNations(self, xmlCtx, root): names = [] indices = nations.INDICES for _, section in _xml.getChildren(xmlCtx, root, 'available-nations'): name = section.asString if name not in indices: _xml.raiseWrongXml(xmlCtx, 'available-nations', 'Nation {0:>s} not found'.format(name)) if name not in nations.AVAILABLE_NAMES: LOG_ERROR('Nation ignored, it not found in nations.AVAILABLE_NAMES', name) continue names.append(name) names = sorted(names, cmp=lambda item, other: cmp(GUI_NATIONS_ORDER_INDEX.get(item), GUI_NATIONS_ORDER_INDEX.get(other))) return names
def _vehicleComparisonKey(cls, vehicle): return (GUI_NATIONS_ORDER_INDEX.get(vehicle.nationName), -vehicle.level, vehicle.userName)
def _compareRewardsByNation(first, second): return cmp( GUI_NATIONS_ORDER_INDEX.get(_extractRewardNation(first[0]), NONE_INDEX), GUI_NATIONS_ORDER_INDEX.get(_extractRewardNation(second[0]), NONE_INDEX))