Author: humbedooh
Date: Thu Mar 26 11:40:48 2015
New Revision: 1669328
URL: http://svn.apache.org/r1669328
Log:
append vote types via function,
remove loop from FiC
Modified:
steve/trunk/pysteve/lib/constants.py
steve/trunk/pysteve/lib/plugins/ap.py
steve/trunk/pysteve/lib/plugins/cop.py
steve/trunk/pysteve/lib/plugins/dh.py
steve/trunk/pysteve/lib/plugins/fic.py
steve/trunk/pysteve/lib/plugins/fpp.py
steve/trunk/pysteve/lib/plugins/mntv.py
steve/trunk/pysteve/lib/plugins/stv.py
steve/trunk/pysteve/lib/plugins/yna.py
Modified: steve/trunk/pysteve/lib/constants.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/constants.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/constants.py (original)
+++ steve/trunk/pysteve/lib/constants.py Thu Mar 26 11:40:48 2015
@@ -19,6 +19,18 @@ VOTE_TYPES = (
)
+def appendVote(*types):
+ global VOTE_TYPES
+ for t in types:
+ found = False
+ for v in VOTE_TYPES:
+ if v['key'] == t['key']:
+ found = True
+ break
+ if not found:
+ VOTE_TYPES += (t,)
+
+
# For vote types with N number of seats/spots, this value denotes
# the max number of useable types to display via the API
MAX_NUM = 10
\ No newline at end of file
Modified: steve/trunk/pysteve/lib/plugins/ap.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/ap.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/ap.py (original)
+++ steve/trunk/pysteve/lib/plugins/ap.py Thu Mar 26 11:40:48 2015
@@ -64,7 +64,7 @@ def verifyAP(basedata, issueID, voterID,
raise Exception("You are not allowed to cast a binding vote!")
-constants.VOTE_TYPES += (
+constants.appendVote(
{
'key': "ap",
'description': "ASF PMC Style vote (YNA with binding votes)",
Modified: steve/trunk/pysteve/lib/plugins/cop.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/cop.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/cop.py (original)
+++ steve/trunk/pysteve/lib/plugins/cop.py Thu Mar 26 11:40:48 2015
@@ -158,7 +158,7 @@ def tallyCOP(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "cop1",
'description': "Candidate or Party Vote with 1 seat",
@@ -174,7 +174,7 @@ constants.VOTE_TYPES += (
# Add ad nauseam
for i in range(2,constants.MAX_NUM+1):
- constants.VOTE_TYPES += (
+ constants.appendVote (
{
'key': "cop%02u" % i,
'description': "Candidate or Party Vote with %u seats" % i,
Modified: steve/trunk/pysteve/lib/plugins/dh.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/dh.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/dh.py (original)
+++ steve/trunk/pysteve/lib/plugins/dh.py Thu Mar 26 11:40:48 2015
@@ -85,7 +85,7 @@ def tallyDH(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "dh1",
'description': "D'Hondt Election with 1 seat",
@@ -98,7 +98,7 @@ constants.VOTE_TYPES += (
# Add ad nauseam
for i in range(2,constants.MAX_NUM+1):
- constants.VOTE_TYPES += (
+ constants.appendVote (
{
'key': "dh%u" % i,
'description': "D'Hondt Election with %u seats" % i,
Modified: steve/trunk/pysteve/lib/plugins/fic.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/fic.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/fic.py (original)
+++ steve/trunk/pysteve/lib/plugins/fic.py Thu Mar 26 11:40:48 2015
@@ -76,7 +76,7 @@ def tallyFIC(votes, issue):
x = 0
for c in winners:
i = ord(c) - ord('a')
- winnernames.append("%s (%u points)" % ( candidates[i],
heapq.nlargest(numseats, matrix.values())[x]))
+ winnernames.append("%s (%u points)" % ( candidates[i], bignums[x]))
x+=1
# Return the data
@@ -87,7 +87,7 @@ def tallyFIC(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote(
{
'key': "fic1",
'description': "First in Class Votes with 1 point max",
@@ -100,7 +100,7 @@ constants.VOTE_TYPES += (
# Add ad nauseam
for i in range(2,constants.MAX_NUM+1):
- constants.VOTE_TYPES += (
+ constants.appendVote (
{
'key': "fic%u" % i,
'description': "First in Class Votes with %u points max" % i,
Modified: steve/trunk/pysteve/lib/plugins/fpp.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/fpp.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/fpp.py (original)
+++ steve/trunk/pysteve/lib/plugins/fpp.py Thu Mar 26 11:40:48 2015
@@ -71,7 +71,7 @@ def tallyFPP(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "fpp",
'description': "First Past the Post (FPP) Election",
Modified: steve/trunk/pysteve/lib/plugins/mntv.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/mntv.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/mntv.py (original)
+++ steve/trunk/pysteve/lib/plugins/mntv.py Thu Mar 26 11:40:48 2015
@@ -80,7 +80,7 @@ def tallyMNTV(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "mntv1",
'description': "Multiple Non-Transferable Votes with 1 seat",
@@ -93,7 +93,7 @@ constants.VOTE_TYPES += (
# Add ad nauseam
for i in range(2,constants.MAX_NUM+1):
- constants.VOTE_TYPES += (
+ constants.appendVote (
{
'key': "mntv%u" % i,
'description': "Multiple Non-Transferable Votes with %u seats" % i,
Modified: steve/trunk/pysteve/lib/plugins/stv.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/stv.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/stv.py (original)
+++ steve/trunk/pysteve/lib/plugins/stv.py Thu Mar 26 11:40:48 2015
@@ -167,7 +167,7 @@ def tallySTV(votes, issue):
}
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "stv1",
'description': "Single Transferable Vote with 1 seat",
@@ -180,7 +180,7 @@ constants.VOTE_TYPES += (
# Add ad nauseam
for i in range(2,constants.MAX_NUM+1):
- constants.VOTE_TYPES += (
+ constants.appendVote (
{
'key': "stv%u" % i,
'description': "Single Transferable Vote with %u seats" % i,
Modified: steve/trunk/pysteve/lib/plugins/yna.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/yna.py?rev=1669328&r1=1669327&r2=1669328&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/yna.py (original)
+++ steve/trunk/pysteve/lib/plugins/yna.py Thu Mar 26 11:40:48 2015
@@ -45,7 +45,7 @@ def validateYNA(vote, issue):
return "Invalid vote. Accepted votes are: %s" % ", ".join(letters)
return None
-constants.VOTE_TYPES += (
+constants.appendVote (
{
'key': "yna",
'description': "YNA (Yes/No/Abstain) vote",