Subversion Repositories Local Hare Voting

Rev

Rev 39 | Rev 44 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 40
Line 51... Line 51...
51
        trace("\tselecting winning candidate randomly from %s" % lWin)
51
        trace("\tselecting winning candidate randomly from %s" % lWin)
52
        randcalls += 1
52
        randcalls += 1
53
        return random.choice(lWin)
53
        return random.choice(lWin)
54
 
54
 
55
    # Check to see if only enough candidates remain
55
    # Check to see if only enough candidates remain
-
 
56
    ## TODO: sort by len(tally[c]) to choose larger winners first
-
 
57
    ## randomize and count if some with equal votes
56
    n = 0
58
    n = 0
57
    last = ""
59
    last = ""
58
    for candidate in tally.keys():
60
    for c in tally.keys():
59
        if candidate not in winners and candidate not in losers:
61
        if c not in winners and c not in losers:
60
            last = candidate
62
            last = c
61
            n = n + 1
63
            n = n + 1
62
    if nWinners - len(winners) >= n:
64
    if nWinners - len(winners) >= n:
-
 
65
        trace("\tremaining winner(s) have fewer than quota (%d) ballots" %
-
 
66
            quota)
63
        return last
67
        return last
64
    return
68
    return
65
 
69
 
66
def redistributeWinner(winner, winners, losers, tally, quota):
70
def redistributeWinner(winner, winners, losers, tally, quota):
67
    global randcalls
71
    global randcalls