@@ -0,0 +1,1549 @@
+# -*- coding: utf-8 -*-%0A%0A%0A# Suq1 -- An ad hoc Python toolbox for a web service%0A# By: Emmanuel Raviart %3Cemmanuel@raviart.com%3E%0A#%0A# Copyright (C) 2009, 2010, 2011, 2012 Easter-eggs & Emmanuel Raviart%0A# Copyright (C) 2013, 2014 Easter-eggs, Etalab & Emmanuel Raviart%0A# https://github.com/eraviart/suq1%0A#%0A# This file is part of Suq1.%0A#%0A# Suq1 is free software; you can redistribute it and/or modify%0A# it under the terms of the GNU Affero General Public License as%0A# published by the Free Software Foundation, either version 3 of the%0A# License, or (at your option) any later version.%0A#%0A# Suq1 is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU Affero General Public License for more details.%0A#%0A# You should have received a copy of the GNU Affero General Public License%0A# along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0A%0A%22%22%22Helpers to handle ranked items (ie a list of items sorted by rank; items of the same rank being in the same sublist)%0A%22%22%22%0A%0A%0Adef iter_ranked_items(items):%0A    if items is not None:%0A        for rank, same_rank_items in enumerate(items):%0A            for item in iter_same_rank_items(same_rank_items):%0A                yield rank, item%0A%0A%0Adef iter_same_rank_items(same_rank_items):%0A    if same_rank_items is not None:%0A        if isinstance(same_rank_items, list):%0A            for item in same_rank_items:%0A                yield item%0A        else:%0A            yield same_rank_items%0A%0A

Add module to handle ranked items (for Condorcet-Schulze voting method).