ConverterBallotToVeto¶
-
class
whalrus.
ConverterBallotToVeto
(priority: whalrus.priorities.priority.Priority = Priority.UNAMBIGUOUS, order_priority: whalrus.priorities.priority.Priority = None, plurality_priority: whalrus.priorities.priority.Priority = None, veto_priority: whalrus.priorities.priority.Priority = None, one_name_priority: whalrus.priorities.priority.Priority = None)[source]¶ Default converter to a
BallotVeto
.- Parameters
priority (Priority) – Serves as a default value for the other parameters if they are not explicitly mentioned. Default:
Priority.UNAMBIGUOUS
.order_priority (Priority) – Option passed to
BallotOrder.last()
. Default:priority
.plurality_priority (Priority) – Option passed to
BallotPlurality.last()
. Default:priority
.veto_priority (Priority) – Option passed to
BallotVeto.last()
. Default:priority
.one_name_priority (Priority) – Option passed to
BallotOneName.last()
. Default:priority
.
Examples
Typical usages:
>>> converter = ConverterBallotToVeto() >>> converter(BallotOneName('a', candidates={'a', 'b'})) BallotVeto('a', candidates={'a', 'b'}) >>> converter(BallotPlurality('a', candidates={'a', 'b'})) BallotVeto('b', candidates={'a', 'b'}) >>> converter({'a': 10, 'b': 7, 'c':0}) BallotVeto('c', candidates={'a', 'b', 'c'}) >>> converter('a ~ b > c') BallotVeto('c', candidates={'a', 'b', 'c'}) >>> converter([{'a', 'b'}, 'c']) BallotVeto('c', candidates={'a', 'b', 'c'})
Use options for the restrictions:
>>> converter = ConverterBallotToVeto(priority=Priority.ASCENDING) >>> converter('a > b ~ c') BallotVeto('c', candidates={'a', 'b', 'c'})