You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2016/03/08 13:30:15 UTC

svn commit: r1734062 - /steve/trunk/pysteve/lib/plugins/stv.py

Author: humbedooh
Date: Tue Mar  8 12:30:15 2016
New Revision: 1734062

URL: http://svn.apache.org/viewvc?rev=1734062&view=rev
Log:
fallback for makeLetter as well

Modified:
    steve/trunk/pysteve/lib/plugins/stv.py

Modified: steve/trunk/pysteve/lib/plugins/stv.py
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/stv.py?rev=1734062&r1=1734061&r2=1734062&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/stv.py (original)
+++ steve/trunk/pysteve/lib/plugins/stv.py Tue Mar  8 12:30:15 2016
@@ -30,13 +30,17 @@ from lib import constants
 
 debug = []
 
-def makeLetter(num):
-    x = ord('A')
-    while num > 25:
-        x += 1
-        num -= 25
-    letter = chr(x) + chr(ord('A') + num)
-    return letter
+def makeLetter(num, version = 2):
+    if version == 1:
+        return ord('A' + num)
+    else:
+        x = ord('A')
+        while num > 25:
+            x += 1
+            num -= 25
+        letter = chr(x) + chr(ord('A') + num)
+        return letter
+
 
 def validateSTV(vote, issue):
     "Tries to validate a vote, returns why if not valid, None otherwise"
@@ -358,7 +362,7 @@ def tallySTV(votes, issue, version = 2):
     candidates = {}
     z = 0
     for c in issue['candidates']:
-        candidates[makeLetter(z)] = c['name']
+        candidates[makeLetter(z, version)] = c['name']
         z += 1
 
     # run the stv calc