3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 use Carp qw(carp croak);
22 use Fcntl ':flock'; # import LOCK_* constants
24 use Digest::MD5 qw(md5 md5_hex md5_base64);
29 dvt-simple2tally - create a tally sheet from manual input
35 dvt-simple2tally -c /path/to/config < input
41 Converts an input file in ad-hoc form to tally.txt
46 =head2 Internal Implementation
48 This routine pays attention to configuration variables Tally_File,
55 die sprintf "bad format: stdin:%d: %s\n", STDIN->input_line_number, $m;
60 # die "Internal Error!" unless defined $params{'Configuration'};
61 # my $confref = $params{'Configuration'}->get_config_ref();
62 # my $dvt = $params{'Configuration'};
63 # my %Config = %{ $confref };
65 # my $tallyfile = $Config{'Tally_File'};
68 # grep {m/^Option_[[:alnum:]]+$/ && $Config{$_}; } sort keys %Config;
70 my @valid_options = qw(D U O V FD);
73 foreach my $ix (0..$#valid_options) {
74 $opt2ix{$valid_options[$ix]} = $ix;
82 badformat "missing voter name" unless s/^(\S+)\:\s*//;
87 while (s{\(([^()]+)\)}{
88 my $x = $1; $x =~ s/[ =]+/=/g; $x;
92 print "# normalised $_ ($voter)\n";
94 my @ranks = ('-',) x @valid_options;
96 foreach (split /\s+/) {
99 defined $ix or badformat "unknown option $_ ($voter)";
106 } @ranks), " ", $voter, "\n"
114 # my $optdesc = Devotee->Optdesc();
115 # GetOptions (%$optdesc);
116 # my $dvt = Devotee->new(%::ConfOpts);
118 # $dvt->validate(%::ConfOpts) unless
119 # defined $::ConfOpts{'Config File'} && -r $::ConfOpts{'Config File'};
120 # $dvt->lock_vote_dir();
121 &create_tally('Configuration' => $dvt);
122 # $dvt->unlock_vote_dir();
140 Ian Jackson <ijackson@chiark.greenend.org.uk>
142 =head1 COPYRIGHT AND LICENSE
144 This script is a part of the Devotee package, and is
146 Copyright (c) 2014 Ian Jackson <ijackson@chiark.greenend.org.uk>
148 This program is free software; you can redistribute it and/or modify
149 it under the terms of the GNU General Public License as published by
150 the Free Software Foundation; either version 2 of the License, or
151 (at your option) any later version.
153 This program is distributed in the hope that it will be useful,
154 but WITHOUT ANY WARRANTY; without even the implied warranty of
155 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
156 GNU General Public License for more details.
158 You should have received a copy of the GNU General Public License
159 along with this program; if not, write to the Free Software
160 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA