diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2021-06-17 23:56:42 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2021-06-17 23:56:42 -0700 |
commit | 8e9679101b638f65af8be2e034263efed09bf22e (patch) | |
tree | 32efacbe186552bb1594f228390628ea56cb5ce4 /countify | |
parent | README.md: refresh docs (diff) | |
download | elections-8e9679101b638f65af8be2e034263efed09bf22e.tar.gz elections-8e9679101b638f65af8be2e034263efed09bf22e.tar.bz2 elections-8e9679101b638f65af8be2e034263efed09bf22e.zip |
Votify: improvements from re-using the codebase for another project
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'countify')
-rwxr-xr-x | countify | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -19,9 +19,13 @@ BEGIN { push @INC, $dirname; } -use POSIX; +use Cwd qw(abs_path); +use File::Basename; +use File::Spec::Functions; use Getopt::Long; use List::Util; +use POSIX; + use Votify 'official'; use strict; @@ -94,12 +98,15 @@ if ($opt{'collect'}) { $master->collect($vl->voters); for my $o ($ol->officials) { my ($uid, $home) = (getpwnam $o)[2,7]; - mkdir "$home/results-$election"; - $master->write("$home/results-$election/master-$election"); - $vl->write("$home/results-$election/confs-$election"); + $home = "/home/$o" unless defined $home; + mkdir catfile("$home", "results-$election"); + $master->write_master("$home/results-$election/master-$election"); + $master->write_casting_voters("$home/results-$election/casting-voters-$election"); + $vl->write_confs("$home/results-$election/confs-$election"); chown $uid, -1, "$home/results-$election", "$home/results-$election/master-$election", - "$home/results-$election/confs-$election"; + "$home/results-$election/confs-$election", + "$home/results-$election/casting-voters-$election"; } exit 0; } @@ -107,7 +114,7 @@ if ($opt{'collect'}) { if ($opt{'rank'}) { my ($master) = MasterBallot->new($election, $vl); my (@candidates, @winner, @ranked, @ranks); - $master->read("$ENV{HOME}/results-$election/master-$election"); + $master->read_master("$ENV{HOME}/results-$election/master-$election"); $master->generate_candidates(); @candidates = sort keys %{$master->{'candidates'}}; |