Skip to content

Commit

Permalink
Rewrite so that we can detect necessary additions and removals.
Browse files Browse the repository at this point in the history
  • Loading branch information
iay committed Apr 28, 2006
1 parent 11f44d5 commit c2f1d48
Showing 1 changed file with 73 additions and 9 deletions.
82 changes: 73 additions & 9 deletions build/addresses.pl
Original file line number Diff line number Diff line change
@@ -1,18 +1,82 @@
#!/usr/bin/perl

open(XML,"../xml/sdss-metadata-unsigned.xml") || die "could not open input file";
#
# Load list addresses.
#
open(LIST, "list.txt") || die "could not open list addresses file";
while (<LIST>) {
chomp; # remove \n
$list{$_} = 1 unless $_ eq '';
}
close LIST;

#
# Load extra addresses.
#
open(EXTRAS, "extra_addresses.txt") || die "could not open extra addresses file";
while (<EXTRAS>) {
chomp; # remove \n
$extras{$_} = 1 unless $_ eq '';
}
close EXTRAS;

#
# Load addresses from the metadata.
#
open(XML,"../xml/sdss-metadata-unsigned.xml") || die "could not open input file";
while (<XML>) {
if (/<EmailAddress>mailto:(.*)<\/EmailAddress>/) {
if (!defined($lowered{lc $1})) {
$lowered{lc $1} = $1;
push @addresses, $1;
if (/<EmailAddress>(mailto:)?(.*)<\/EmailAddress>/) {
$metadata{$2} = 1;
}
}
}
close XML;

foreach $addr (@addresses) {
print $addr, "\n";
#
# Now figure out the addresses we want to see in the mailing list.
# Make them lower case for comparisons.
#
foreach $addr (keys %extras) {
$wanted{lc $addr} = $addr;
}
foreach $addr (keys %metadata) {
$wanted{lc $addr} = $addr;
}

close XML;
#
# Similar lower-case hash for the current list.
#
foreach $addr (keys %list) {
$have{lc $addr} = $addr;
}

#
# Cancel the ones that are *in* the mailing list from the wanted
# collection. Whine about (now) unwanted entries in the
# mailing list.
#
$first = 1;
foreach $addr (keys %have) {
my $a = $have{$addr};
if (defined($wanted{$addr})) {
delete $wanted{$addr};
} else {
if ($first) {
$first = 0;
print "\nDelete unwanted: \n";
}
print "$a\n";
}
}

#
# List the ones that are wanted, but not yet in the list.
#
$first = 1;
foreach $addr (keys %wanted) {
my $a = $wanted{$addr};
if ($first) {
$first = 0;
print "\nAdd wanted: \n";
}
print "$a\n";
}

0 comments on commit c2f1d48

Please sign in to comment.