chiark / gitweb /
normal2openstvtxt: produces something that openstv accepts; need to check
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 22 Aug 2016 16:59:27 +0000 (17:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 22 Aug 2016 16:59:27 +0000 (17:59 +0100)
normal2openstvtxt [new file with mode: 0755]

diff --git a/normal2openstvtxt b/normal2openstvtxt
new file mode 100755 (executable)
index 0000000..495bba9
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl -w
+
+for (;;) {
+    $_ = <>;
+    if (m/^\| /) {
+       if (s/ _?[Ss]eats=(\d+)\s/ /) {
+           print STDERR "# openstv-run-election -s $1\n";
+       }
+       die if m/ [A-Z]/;
+       warn if m/ [a-z]/;
+    } elsif (s/^\w+ = [^|]+ \|//) {
+       die if m/ [A-Z]/;
+       warn if m/ [a-z]/;
+    } elsif (s/^\w+ \: ([^|]*) \|//) {
+       print $1,"\n" or die $! if length $1;
+       die if m/ [A-Z]/;
+       warn if m/ [a-z]/;
+    } elsif (m/^\.$/) {
+       last;
+    } else {
+       die;
+    }
+}