This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 870f5661cb04213b90109e55c63d41da6bf97ef8
Author: Greg Stein <[email protected]>
AuthorDate: Fri Mar 6 09:07:13 2026 -0600

    factor out load_v3, for whatif support
---
 monitoring/stv_tool.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/monitoring/stv_tool.py b/monitoring/stv_tool.py
index 6b23243..e0b1d76 100755
--- a/monitoring/stv_tool.py
+++ b/monitoring/stv_tool.py
@@ -96,6 +96,25 @@ def load_votes(fname):
   return names, votes
 
 
+def load_v3(jvalue):
+    "Given JVALUE loaded from a v3 .json file, return LABELMAP and 
VOTESTRINGS."
+
+    # Find the single/first STV issue in the results.
+    for issue in jvalue['results'].values():
+        if issue['vtype'] == 'stv':
+            break
+    else:
+        raise Exception('No STV issue found.')
+
+    data = issue['supporting_data']
+    labelmap = data['labelmap']
+
+    votes_by_label = data['votestrings']
+    votes = [[labelmap[l] for l in vote.split(',')] for vote in votes_by_label]
+
+    return labelmap, votes
+
+
 def read_votefile(fname):
   """Return a list of votestrings, throwing out who produced each.
 
@@ -492,19 +511,7 @@ def main(argv):
     # This is a modern (v3 starting in 2026) vote-results.json file.
     # It contains everything we need.
 
-    # Find the single/first STV issue in the results.
-    for issue in jvalue['results'].values():
-      if issue['vtype'] == 'stv':
-        break
-    else:
-      print('No STV issue found.')
-      sys.exit(1)
-
-    data = issue['supporting_data']
-    labelmap = data['labelmap']
-
-    votes_by_label = data['votestrings']
-    votes = [[labelmap[l] for l in vote.split(',')] for vote in votes_by_label]
+    labelmap, votes = load_v3(jvalue)
 
   else:
     # Older styles of vote records.

Reply via email to