Files
oddmuse/scripts/merge-banned-lists
Alex Schroeder 72cd669bf0 Changed nearly remaining code from GPLv2 to GPLv3
There were some files that did not offer "or (at your option) any later
version" in their license and these had to be left alone. This should
solve the incorrect FSF address issue #4 on GitHub.
2016-08-16 18:01:26 +02:00

55 lines
1.8 KiB
Perl

#!/usr/bin/perl -w
# merge-banned-list -- copy BannedContent from one wiki to another
# Copyright (C) 2004, 2005 Alex Schroeder <alex@emacswiki.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This program copies the banned list from A to B, removing comments
# from A and keeping comments from B, and adding a date to entries
# that have none.
# $Id: merge-banned-lists,v 1.1 2006/04/26 23:36:29 as Exp $</p>'
use strict;
use LWP::UserAgent;
sub GetRaw {
my $uri = shift;
my $ua = LWP::UserAgent->new;
$ua->agent('Mozilla/5.0'); # some block libwww-perl
my $response = $ua->get($uri);
die $uri . ": " . $response->status_line . "\n" unless $response->is_success;
return $response->content;
}
sub Main {
my ($source, $target) = map {
$_ = GetRaw($_);
} @ARGV;
my ($sec, $min, $hour, $mday, $mon, $year) = gmtime();
my $date = sprintf('%4d-%02d-%02d', $year+1900, $mon+1, $mday);
my $result = join("\n", grep(/^(#|\s*$)/, split(/\n/, $target)));
$result .= "\n" . join("\n", map {
$_ .= " # $date" unless /#\s*\d\d\d\d-\d\d-\d\d/;
$_;
} sort(grep(/^[^#]/, split(/\n/, $source))));
print $result, "\n";
}
if ($#ARGV != 1 && $#ARGV != 2) {
die "Usage: $0 source-url target-url\n"
}
Main();