예제 #1
0
                    if value == "on":
                        counter[candidate] += 1

            for candidate, value in counter.items():
                print("%s: Y:%s N:%s [%s%%]" % (candidate, value,
                     count[state] - value, "%.2f" % (value / count[state] * 100)))
        print()

    # Phase 2: Ranking
    if args.ranking:
        print ("# Ranking")
        # Convert ballots to CSV for schulze.py counting
        csvs = defaultdict(list)
        for state, ballots in parsed_ranking.items():
            candidates = list(sorted(parsed_ranking[state][0].keys()))
            csvs[state].append(",".join(candidates))
            for ballot in ballots:
                csvs[state].append(",".join([ballot[candidate] for candidate in candidates]))

        parsed_csvs = {}
        for state, csv in csvs.items():
            parsed_csvs[state] = "\n".join(csv)

        for state, csv in parsed_csvs.items():
            print("\n## %s" % state)
            run_election(csv, *[], **{
                "show_errors": args.show_errors,
                "html": args.html,
                "urlencode": True
            })
예제 #2
-1
                        counter[candidate] += 1

            for candidate, value in counter.items():
                print("%s: Y:%s N:%s [%s%%]" % (candidate, value,
                     count[position] - value, "%.2f" % (value / count[position] * 100)))
        print()

    # Phase 2: Ranking
    if args.ranking:
        print ("# Ranking")
        # Convert ballots to CSV for schulze.py counting
        csvs = defaultdict(list)
        for position, ballots in parsed_ranking.items():
            candidates = list(sorted(parsed_ranking[position][0].keys()))
            csvs[position].append(",".join(candidates))
            for ballot in ballots:
                csvs[position].append(",".join([ballot[candidate] for candidate in candidates]))

        parsed_csvs = {}
        for position, csv in csvs.items():
            parsed_csvs[position] = "\n".join(csv)

        for position, csv in parsed_csvs.items():
            print("\n## %s" % position)
            run_election(csv, *args.withdraw or [], **{
                "show_errors": args.show_errors,
                "html": args.html,
                "urlencode": True,
                "first_prefs": True
            })