-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite so that we can detect necessary additions and removals.
- Loading branch information
Showing
1 changed file
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
| } |