Thread View: news.software.nntp
15 messages
15 total messages
Started by ez_doesit
Wed, 14 Apr 1999 00:00
newsgroups file
Author: ez_doesit
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
15 lines
832 bytes
832 bytes
hi, could someone tell me what the results or consequences are of putting a new 'newsgroups' file in 'news/etc' when using innd1.7.2 ? ( i did not change anything to the active file) Thx in advance, -Ez Doesit
Re: newsgroups file
Author: Russ Allbery
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
16 lines
1142 bytes
1142 bytes
Fuffly <hipQrimE@myremarQ.coM> writes: > The newsgroups file is purely informational, only really used by nnrpd > for XGTITLE and LIST NEWSGROUPS. Aside from the newgroup control > message, innd does not make use of it. (Sadly, INN's checkgroups does > nothing useful with the information, though it could and should.) What are you thinking of in particular? INN's checkgroups processing does make use of the descriptions in order to determine whether a group is moderated. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: newsgroups file
Author: Jeremy
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
22 lines
1577 bytes
1577 bytes
Russ Allbery <rra@stanford.edu> wrote:
>> The newsgroups file is purely informational, only really used by nnrpd
>> for XGTITLE and LIST NEWSGROUPS. Aside from the newgroup control
>> message, innd does not make use of it. (Sadly, INN's checkgroups does
>> nothing useful with the information, though it could and should.)
>
> What are you thinking of in particular?
>
> INN's checkgroups processing does make use of the descriptions in order to
> determine whether a group is moderated.
But it doesn't add the descriptions to the newsgroups file, a fact which
I'm sure contributes greatly to the lack of upkeep of that file on many
servers, including mine, I admit...
--
Jeremy | jeremy@exit109.com
"The sky would not fall if an American President spoke the truth."
--Ronald Reagan
Re: newsgroups file
Author: Russ Allbery
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
19 lines
1472 bytes
1472 bytes
Fuffly <hipQrimE@myremarQ.coM> writes: > That's got nothing to do with maintaining the newsgroups file, which has > been rendered largely useless at most sites from neglect. If there was > a reasonable expectation that the information would be available, there > would have been more incentive for newsreaders to display the > information promiently. Hell, lots of recent readers don't even try any > more. True. I maintain mine fairly religiously (in fact, I run a script on it periodically to clean out lines for groups that don't exist any more, make sure that everything in the active file has a description, and make sure that the (Moderated) tags are correct and that all lines are 80 characters or less). -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: newsgroups file
Author: Fuffly
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
23 lines
1841 bytes
1841 bytes
>>>>> "ez" == ez doesit <ez_doesit@online.be> writes:
ez> could someone tell me what the results or consequences are of
ez> putting a new 'newsgroups' file in 'news/etc' when using innd1.7.2 ?
ez> ( i did not change anything to the active file)
The newsgroups file is purely informational, only really used by nnrpd
for XGTITLE and LIST NEWSGROUPS. Aside from the newgroup control
message, innd does not make use of it. (Sadly, INN's checkgroups does
nothing useful with the information, though it could and should.)
The only reader I can think of that truly cares if newsgroups is
missing or incomplete is lynx.
So, you are pretty much free to play with newsgroups all you like on a
live server.
--
<URL:http://members.xoom.com/meowing/>
"There is nothing worse than having a spare couple of hours and you can't
find an open server to abuse." - Tim Thorne
Re: newsgroups file
Author: Russ Allbery
Date: Wed, 14 Apr 1999 00:00
Date: Wed, 14 Apr 1999 00:00
186 lines
7972 bytes
7972 bytes
Jeremy <jeremy@exit109.com> writes:
> I keep meaning to write up a nice little script that'll take all the
> files in my directory-o-checkgroups, my existing newsgroups file, and
> the ISC newsgroups file, and spit out a nice complete newsgroups file.
> The trick is when you get two descriptions for the same group in the
> input and have to decide which to use. Someday I'll get around to that.
> Hmm, maybe I'll do that this week.
Attached is my cleaning script in case it may be of some help to someone.
A couple of things to note about this: It doesn't do locking like it
should, mostly because back when I wrote it originally I didn't understand
the locking mechanisms (the comments on this subject are wrong). It also
strictly enforces an 80-character limit, *including* the (Moderated) tag.
Yes, I actually invent new descriptions for those Big Eight, de.*, it.*,
etc. groups that have descriptions that are too long. Yes, this means
that my newsgroups file probably has a few things that are absolutely
hilarious Italian, since I don't speak it. :)
(I do that because a copy of the newsgroups file is stuck in a public
directory every night for people to read through and search, and I didn't
want weird wrapping in 80 column screens.)
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
#!/usr/bin/perl
$version = q$Id: ngclean,v 0.5 1998/06/27 09:46:51 eagle Exp $;
#
# ngclean -- Clean up the newsgroups file based on the active file.
#
# Written by Russ Allbery <rra@stanford.edu>
# Copyright 1997, 1998 Board of Trustees, Leland Stanford Jr. University
############################################################################
# Site configuration
############################################################################
# The full path to the active file.
$active = '/var/news/data/active';
# The full path to the newsgroups file.
$newsgroups = '/var/news/data/newsgroups';
# The directory to use for temporary files.
$tempdir = $ENV{TMPDIR} || '/tmp';
############################################################################
# Modules and delcarations
############################################################################
require 5.001;
use strict;
use vars qw($active $newsgroups $tempdir $version);
############################################################################
# File parsing and format
############################################################################
# Read the active file into the passed hash, storing the group names as the
# keys and the moderation status as the values.
sub read_active (\%) {
my $groups = shift;
open (ACTIVE, $active) or die "$0: cannot open $active: $!\n";
print 'Scanning active file...';
%$groups = map { (split)[0,3] } <ACTIVE>;
close ACTIVE;
print "done\n";
}
# Takes in a newsgroup name and adds the right number of tabs after it for
# an entry in a newsgroups file.
sub add_tabs {
my $newsgroup = shift;
my $extra = int ((23 - length $newsgroup) / 8);
$extra = $extra > 0 ? $extra : 0;
return $newsgroup . ("\t" x (1 + $extra));
}
# Prompts for and reads in a newsgroup description from STDIN.
sub get_description {
my $newsgroup = shift;
print "Enter description:\n";
print add_tabs ($newsgroup);
my $description = <STDIN>;
$description =~ s/\s+$//;
return $description;
}
############################################################################
# Main routine
############################################################################
# Clean up $0 for error messages.
$0 =~ s%.*/%%;
$| = 1;
# Read in the active file.
my (%active, %description);
read_active (%active);
# Now, we're going to do editing of the newsgroups file, which inherently
# involves a race condition since the server, when creating a new group,
# just does the equivalent of cat >> to the file. Unfortunately, there's no
# way of avoiding that entirely, but we can at least make the window small
# by checking the file size before and afterwards.
my $size = -s $newsgroups;
unless ($size) { die "$0: newsgroups file is empty?\n" }
# Open the newsgroups file to grab the current descriptions.
open (NEWSGROUPS, $newsgroups) or die "$0: cannot open $newsgroups: $!\n";
# Walk the newsgroups file, inspecting each line. We're checking for lines
# that are too long, fixing tabbing, removing lines for groups that no
# longer exist, and looking for groups without newsgroup lines. In order to
# find the latter, we delete a group out of the active hash as we find its
# description and then will look at what's left in the hash when we're done.
# We store the descriptions in a parallel hash, and in order to let later
# descriptions for the same group override earlier ones, we check to see if
# there's already an entry in the hash for a group.
while (<NEWSGROUPS>) {
my ($group, $description) = split (/\s+/, $_, 2);
$description =~ s/\s+$//;
if ($description{$group}) {
print "Using newer description for $group\n";
} elsif (!$active{$group}) {
print "Discarding nonexistant group $group\n";
next;
}
if ($description =~ s/( ?\(Moderated\)){2,}$/ (Moderated)/) {
print "$group had duplicate (Moderated) tags, removed\n";
}
my $moderated = /\(Moderated\)$/;
if (!$moderated && $active{$group} eq 'm') {
print "$group is moderated, adding (Moderated) to description\n";
$description .= ' (Moderated)';
} elsif ($moderated && $active{$group} ne 'm') {
print "$group is not moderated, removing (Moderated) from "
. "description\n";
$description =~ s/ ?\(Moderated\)$//;
}
my $maxlength = 80 - length $group;
$maxlength -= 8 - ((length $group) % 8);
$maxlength -= 8 if (length $group < 16);
$maxlength -= 8 if (length $group < 8);
if (length $description > $maxlength) {
print "Line too long (", length $description, "> $maxlength):\n";
print $_;
$description = get_description ($group);
}
$description{$group} = add_tabs ($group) . $description;
delete $active{$group};
}
# See what's left in the active hash and get descriptions for those groups.
for (sort keys %active) {
$description{$_} = add_tabs ($_) . get_description ($_);
}
# Okay, we're done. Sort our descriptions and print them out.
open (NEW, "> $tempdir/ngclean.$$") or die "$0: can't open temp file: $!\n";
for (sort keys %description) {
print NEW $description{$_}, "\n";
}
close NEW;
# Check to make sure the newsgroups file is still the same size as when we
# started, and if so, replace it in place. If not, tell the user where we
# left the temporary copy.
if (-s $newsgroups == $size) {
rename $newsgroups, "$newsgroups.old"
or die "$0: unable to save copy of old newsgroups file: $!\n";
system 'mv', '-f', "$tempdir/ngclean.$$", $newsgroups
and die "$0: unable to mv newsgroups file: status $?\n";
} else {
warn "$newsgroups appears to have changed.\n";
warn "Leaving the new copy in $tempdir/ngclean.$$\n";
exit 1;
}
Re: newsgroups file
Author: Fuffly
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
31 lines
2326 bytes
2326 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:
Russ> Fuffly <hipQrimE@myremarQ.coM> writes:
>> The newsgroups file is purely informational, only really used by nnrpd
>> for XGTITLE and LIST NEWSGROUPS. Aside from the newgroup control
>> message, innd does not make use of it. (Sadly, INN's checkgroups does
>> nothing useful with the information, though it could and should.)
Russ> What are you thinking of in particular?
Russ> INN's checkgroups processing does make use of the descriptions
Russ> in order to determine whether a group is moderated.
That's got nothing to do with maintaining the newsgroups file, which
has been rendered largely useless at most sites from neglect. If
there was a reasonable expectation that the information would be
available, there would have been more incentive for newsreaders to
display the information promiently. Hell, lots of recent readers
don't even try any more.
Think of how much silliness could have been avoided, for example, if
readers were to have seen "The Network extensible Windowing System"
instead of "comp.windows.news".
--
<URL:http://members.xoom.com/meowing/>
"There is nothing worse than having a spare couple of hours and you can't
find an open server to abuse." - Tim Thorne
Re: newsgroups file
Author: Fuffly
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
17 lines
1610 bytes
1610 bytes
>>>>> "BK" == Brad Knowles <brad@shub-internet.org> writes:
BK> <jeremy@exit109.com> wrote:
>> Someday I'll get around to that. Hmm, maybe I'll do that this
>> week.
BK> So, where is the code? I want to see some code, dammit! ;-)
1 4M 3i337 61MM3 W4R32 d00d!
--
<URL:http://members.xoom.com/meowing/>
"There is nothing worse than having a spare couple of hours and you can't
find an open server to abuse." - Tim Thorne
Re: newsgroups file
Author: Brad Knowles
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
27 lines
2050 bytes
2050 bytes
In article <7f3hm5$hfm$1@east44.supernews.com>, Jeremy
<jeremy@exit109.com> wrote:
> I keep meaning to write up a nice little script that'll take all the
> files in my directory-o-checkgroups, my existing newsgroups file, and the
> ISC newsgroups file, and spit out a nice complete newsgroups file. The
> trick is when you get two descriptions for the same group in the input
> and have to decide which to use.
It seems to me that this could be incorporated into actsync, and that
you could use the same actsync configuration files to tell you what
newsgroup hierarchies to pay attention to relative to the newsgroup
definitions, in addition to the actual active file itself.
> Someday I'll get around to that. Hmm,
> maybe I'll do that this week.
So, where is the code? I want to see some code, dammit! ;-)
--
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
<http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>
Are you looking for a news feed from a site in the Freenix Top 130?
If so, contact me via private e-mail for details.
Re: newsgroups file
Author: Ben C. O. Grimm
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
19 lines
1558 bytes
1558 bytes
On 14 Apr 1999 17:17:31 -0700, Russ Allbery <rra@stanford.edu> wrote: >Fuffly <hipQrimE@myremarQ.coM> writes: >True. I maintain mine fairly religiously (in fact, I run a script on it >periodically to clean out lines for groups that don't exist any more, make >sure that everything in the active file has a description, and make sure >that the (Moderated) tags are correct and that all lines are 80 characters >or less). Is it available by FTP? :) -- - Ben C. O. Grimm ----------------- Ben.Grimm@wirehub.net - - Wirehub! Internet Engineering - http://www.wirehub.net/ - - Wirehub! Backbone --- http://doema.wirehub.net/wirehub/ - - Private Ponderings ------- http://libertas.wirehub.net/ -
Re: newsgroups file
Author: Fuffly
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
40 lines
2623 bytes
2623 bytes
>>>>> "Jeremy" == Jeremy <jeremy@exit109.com> writes:
Jeremy> But it doesn't add the descriptions to the newsgroups file, a
Jeremy> fact which I'm sure contributes greatly to the lack of upkeep
Jeremy> of that file on many servers, including mine, I admit...
Right. Okay, now Russ gives us the exception that proves the rule,
but this useless newsgroups plague (like the useless active.times
plague I also occasionally rant about) really ought to be taken care
of by the server, by default.
Actually, we can also make an exception for remarQ, because if the
descriptions were available we wouldn't have those wacky, wonderful
WReN substitutes ;)
I realize that these features might seem ancillary, maybe even
trivial, when the emphasis these days seems to be on bigger, better,
faster transit, even at the expense of usefulness to readers (waving
to uniover). But it bothers me that simple, useful features like this
are suffering from bit rot, while at the same time grandiose
super-bouncy hyperlinked FAQ retrieval and the like are being
considered as extensions.
What are the chances that all that stuff can work smoothly when
ancient features like these have yet to be well integrated?
Hey, look at that! Four paragraphs and I didn't even start in on the
sorry state of NEWNE$_Az
R9*^
|
a~
,
NO CARRIER
--
<URL:http://members.xoom.com/meowing/>
"There is nothing worse than having a spare couple of hours and you can't
find an open server to abuse." - Tim Thorne
Re: newsgroups file
Author: Jeremy
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
39 lines
2490 bytes
2490 bytes
Fuffly <hipQrimE@myremarQ.coM> wrote: > Right. Okay, now Russ gives us the exception that proves the rule, > but this useless newsgroups plague (like the useless active.times > plague I also occasionally rant about) really ought to be taken care > of by the server, by default. Well, I have no active.times trouble; that's sort of self-maintaining. But it's a pain that running a checkgroups doesn't update the newsgroups file. > I realize that these features might seem ancillary, maybe even > trivial, when the emphasis these days seems to be on bigger, better, > faster transit, even at the expense of usefulness to readers (waving > to uniover). But it bothers me that simple, useful features like this > are suffering from bit rot, while at the same time grandiose > super-bouncy hyperlinked FAQ retrieval and the like are being > considered as extensions. I keep meaning to write up a nice little script that'll take all the files in my directory-o-checkgroups, my existing newsgroups file, and the ISC newsgroups file, and spit out a nice complete newsgroups file. The trick is when you get two descriptions for the same group in the input and have to decide which to use. Someday I'll get around to that. Hmm, maybe I'll do that this week. > Hey, look at that! Four paragraphs and I didn't even start in on the > sorry state of NEWNE$_Az As a side note, the Sooper Seekret Server Software that RemarQ will be deploying Real Soon Now has a fast and efficient newnews implementation. We will be supporting it. -- Jeremy | jeremy@exit109.com "You've never seen the British Parliament in action, have you? You ought to. It's very similar to Usenet." --Tim Thorne
Re: newsgroups file
Author: Russ Allbery
Date: Thu, 15 Apr 1999 00:00
Date: Thu, 15 Apr 1999 00:00
12 lines
1051 bytes
1051 bytes
Ben C O Grimm <Ben.Grimm@wirehub.net> writes: > Is it available by FTP? :) See other post... I should clean it up some more and document it and maybe give it a few options and then stick it on my ftp site. That's a good idea. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Creating a newsgroups description file (was Re: newsgroups file)
Author: Jeremy
Date: Sat, 17 Apr 1999 00:00
Date: Sat, 17 Apr 1999 00:00
156 lines
5843 bytes
5843 bytes
Brad Knowles <brad@shub-internet.org> wrote:
>> Someday I'll get around to that. Hmm, maybe I'll do that this week.
>
> So, where is the code? I want to see some code, dammit! ;-)
Here ya go. It's quick, it's dirty, it's barely tested, but it just
worked for me. :)
#!/usr/local/bin/perl
#
# mkngfile - make a newsgroup description file from multiple sources
#
# Jeremy Nixon <jeremy@exit109.com>
# $Id: mkngfile,v 1.1 1999/04/17 09:19:25 jeremy Exp $
#
# This program may be used and distributed under the same terms
# as Perl itself.
# This program creates a newsgroup description file, using one or
# several input files containing group descriptions. The resulting
# file will contain a description line for each group in your active
# file.
#
# If the input contains multiple different descriptions for a group,
# the program will prompt interactively for which one to use; or, if
# the --noask option is given, one will be chosen arbitrarily. If a
# group has no description, $default_desc (below) will be used.
#
# The output will be sent to stdout, or to the file specified with
# the --output (or -o) option.
#
# Example - to run with your existing newsgroups file, a local copy
# of the ISC newsgroups file, and a directory containing checkgroups
# files with names like *.check, creating the new file as 'newfile':
# mkngfile -o newfile /news/etc/newsgroups newsgroups checkgroups/*.check
#
# You can set the location of your active file below so you don't
# have to specify it on the command line.
use Getopt::Long;
GetOptions (\%opt, qw(h help a=s active=s ask! o=s output=s)) || usage();
usage() if ($opt{'h'} or $opt{'help'});
usage('No input files specified.') unless (scalar @ARGV > 0);
# If a group has no description, use this.
$default_desc = '???';
# Default to asking which of multiple descriptions to use.
# Comment this out if you want the default to be not to ask.
$opt{'ask'} = 1 unless (defined $opt{'ask'});
# Default to system active file; you may want to change this.
$active_file = $opt{'active'} || $opt{'a'} || '/news/etc/active';
usage('No active file.') unless (-r $active_file);
$output_file = $opt{'output'} || $opt{'o'} || undef;
# Read in the active file and create a hash.
open (F, "<$active_file") || die "Can't open $active: $!\n";
%active = map { (split /\s+/, $_)[0,3] } <F>;
close F;
# Read in all the files and create a hash.
%groups = ();
while (defined ($file = shift @ARGV)) {
unless (open (F, "<$file")) {
print STDERR "Can't open $file: $!\n";
next;
}
while (defined ($line = <F>)) {
chomp $line;
($group,$desc) = split /\s+/, $line, 2;
$desc =~ s/\(Moderated\)//gi;
$desc =~ s/^\s+//;
$desc =~ s/\s+$//;
next if ($desc =~ /^\s*$/ or $desc =~ /^\?+$/ or $desc =~ /no description/i);
$groups{$group}{$desc} = 1;
}
close F;
}
# Go through the active file and find each group's description.
@descriptions = ();
foreach $group (sort keys %active) {
$desc = pick_description ($group);
push @descriptions, "$group\t$desc";
}
# If we have an output file, open it; otherwise STDOUT is used.
if ($output_file) {
open (OUT, ">$output_file") or die "Can't open $output_file: $!\n";
open (STDOUT, ">&OUT") or die "Can't redirect stdout: $!\n";
}
# Print the new file.
map { print "$_\n" } @descriptions;
close OUT if ($output_file);
sub pick_description {
# Given a group, return the description.
# If we have more than one description for a group, we ask the
# user which one to use, or just pick one if --noask is specified.
# If we have no description for a group, use $default_desc.
# If the group is moderated, append '(Moderated)' to the description.
my ($description,$n,$c);
my $ng = shift;
my @descs = sort keys %{$groups{$ng}};
if (scalar @descs < 1) {
$description = $default_desc;
} elsif (scalar @descs == 1) {
$description = $descs[0];
} else {
if ($opt{'ask'}) {
print STDERR "$ng - choose description:\n";
map { print STDERR " ". ++$n .". $_\n" } @descs;
until ($c > 0 and $c <= scalar @descs) {
print STDERR "> ";
$c = <STDIN>;
chomp $c;
}
$description = $descs[--$c];
} else {
$description = $descs[0];
}
}
$description .= ' (Moderated)' if ($active{$ng} =~ /^m/i);
return $description;
}
sub usage {
my $message = shift;
print STDERR "$message\n" if ($message);
print STDERR "\nusage:\n";
print STDERR "mkngfile [options] file [file...]\n";
print STDERR " -h, --help display this message\n";
print STDERR " -a, --active path to active file\n";
print STDERR " -o, --output output file to use instead of stdout\n";
print STDERR " --ask ask which of multiple descriptions to use (default)\n";
print STDERR " --noask don't ask, just pick one\n";
print STDERR "\n";
exit 1;
}
Re: Creating a newsgroups description file (was Re: newsgroups file)
Author: Arthur Hagen
Date: Sat, 17 Apr 1999 00:00
Date: Sat, 17 Apr 1999 00:00
127 lines
4846 bytes
4846 bytes
In article <7f9l34$k0o$1@east44.supernews.com>, Jeremy <jeremy@exit109.com> writes:
> Brad Knowles <brad@shub-internet.org> wrote:
>
> >> Someday I'll get around to that. Hmm, maybe I'll do that this week.
> >
> > So, where is the code? I want to see some code, dammit! ;-)
>
> Here ya go. It's quick, it's dirty, it's barely tested, but it just
> worked for me. :)
>
> #!/usr/local/bin/perl
> #
> # mkngfile - make a newsgroup description file from multiple sources
Good one. I have a much simpler one that will make one
"newsgroups.full" file in addition to the newsgroups file. The
newsgroups file will be shortened to only contain the groups that are
in your active file, and the newsgroups.full file will keep the newest
entry for any newsgroup, whether you carry it or not. That saves a lot
of time for the clients that fetches the newsgroups file, and allows
you to add in the new descriptions if you add new newsgroups. If
anything is changed in or added to the newsgroups file, it takes
precedence over similar entries in the newsgroups.full file, so you can
still run docheckgroups and similar, and run this script afterwards
without losing anything. Saving 30 seconds for every client that
pulls the newsgroups file is nice :-)
Anyhow, here's the script. Add locking and moving the new files
in place automatically if you need it.
Forgive me for committing bad perl.
--- cut here ---
#!/bin/perl
# cleannewsgroups.pl
# Copyright 1997-1999 Arthur Hagen
# This program is Freeware. It's not GPL or Public Domain.
require 5.0;
$DEBUG=1;
# Change the path below!
$dbdir = '/usr/local/news/db';
chdir($dbdir)
or die "Can't cd to '$dbdir'\n";
my %ng;
my @groups;
print "Reading active ...\n" if $DEBUG;
open(INFILE,'<active')
or die "Cant find active file in '$dbdir'\n";
while (<INFILE>) {
my ($group,@rest) = split;
push @groups,$group;
}
print "Reading newsgroups ...\n" if $DEBUG;
open(INFILE,'<newsgroups')
or die "Can't find newsgroups file in '$dbdir'\n";
while (<INFILE>) {
chomp;
my ($group,@rest) = split /\t/;
my $desc = $rest[-1]; # Only the last entry, no need for extra tabs.
# Remove duplicate (Moderated) comments
while ($desc =~ s/\(Moderated\)(\s)+\(Moderated\)/(Moderated)/g)
{};
# Strip trailing spaces too
$desc =~ s/(\s)+$//;
$ng{$group} = $desc;
}
close INFILE;
print "Reading newsgroups.full ...\n" if $DEBUG;
if (open(INFILE,'<newsgroups.full')) {
# No harm done if there aren't any newsgroups.full file. It will
# be created later.
while (<INFILE>) {
chomp;
my ($group,@rest) = split /\t/;
# Let newsgroups take precedence over newsgroups.full
unless ($ng{$group}) {
my $desc = $rest[-1];
while ($desc =~ s/\(Moderated\)(\s)+\(Moderated\)/(Moderated)/g)
{};
$desc =~ s/(\s)+$//;
$ng{$group} = $desc;
}
}
close INFILE;
}
# Remove this part if you want your newsgroups file to be in the same
# order as your active file. I prefer both to be sorted.
print "Sorting groups ...\n" if $DEBUG;
my @groupss = sort @groups;
print "Writing newsgroups.full.n ...\n" if $DEBUG;
open(OUTFILE,'>newsgroups.full.n');
foreach $group (sort keys %ng) {
# One tab is enough. Pretty-printing is for humans, not machines.
print OUTFILE $group,"\t",$ng{$group},"\n";
}
close OUTFILE;
print "Writing newsgroups.n ...\n" if $DEBUG;
open(OUTFILE,'>newsgroups.n');
my $numgroups = scalar @groupss;
for ($i=0;$i<$numgroups;$i++) {
my $group = $groupss[$i];
if (my $desc = $ng{$group}) {
print OUTFILE $group,"\t",$desc,"\n";
}
}
close OUTFILE;
print "Done.\n" if $DEBUG;
exit 0;
--- cut here ---
Regards,
--
*Art
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads