new From field include/exclude ubh patch
[email protected] Thu, 16 Jan 2003 15:24:23 -0500 (EST)
| Newsgroups | gmane.network.ubh |
|---|---|
| Message-ID | <[email protected]> |
This patch adds the from field to the log output. To apply patches: patch -p0 < ubh.patch These patches works against the CVS version, the 1/4/03 is the latest one I checked out. I will post this patch to the files section of yahoo later. Gerard, Could these patches be merged into the ubh3.0b code? ___________________ Jt Chiodi http://www.squeegy.org/ [email protected] ------------------------ Yahoo! Groups Sponsor ---------------------~--> Turn flat surfaces into speakers with the Soundbug. http://us.click.yahoo.com/QWAVSC/onCFAA/xGHJAA/IHFolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
ubh.patch
(text/plain, 10.1 KB)
--- ubh 2003-01-16 14:06:14.000000000 -0500
+++ ubh.newer 2003-01-16 14:06:08.000000000 -0500
@@ -138,8 +138,10 @@
-c <file> Use file as config file instead of default (ubhrc).
-G <group> Process this one group.
-a Process all articles (disregards whether article is marked read).
- -I <regexp> Inclusion search filter (double quote on command line)
- -X <regexp> Exclusion search filter (double quote on command line)
+ -I <regexp> Inclusion search filter for Subject (double quote on command line)
+ -X <regexp> Exclusion search filter for Subject (double quote on command line)
+ -K <regexp> Inclusion search filter for From (double quote on command line)
+ -N <regexp> Exclusion search filter for From (double quote on command line)
-C Clean filenames (change all non alphanumeric to '_')
-L Long filenames (use subject as the filename)
-O [yes|no|skip] Overwrite strategy
@@ -159,7 +161,7 @@
{
my $log = get_logger("ubh::process_options");
- my $error = !getopts('SgMAb:dDc:G:aI:X:CO:zyuw', \%opt);
+ my $error = !getopts('SgMAb:dDc:G:aIK:XN:CO:zyuw', \%opt);
if ($opt{'c'}) {
$platform->set_ubhrcname($opt{'c'});
@@ -186,6 +188,21 @@
}
}
+ if ($opt{'K'}) {
+ eval { "" =~ /$opt{'K'}/ };
+ if ($@) {
+ $log->fatal("invalid -K pattern: ", $@);
+ $error = 1;
+ }
+ }
+
+ if ($opt{'N'}) {
+ eval { "" =~ /$opt{'N'}/ };
+ if ($@) {
+ $log->fatal("invalid -N pattern: ", $@);
+ $error = 1;
+ }
+ }
if ($opt{'w'}) {
print_warranty;
exit(0);
@@ -288,6 +305,12 @@
elsif ($keyword =~ /OPT_X/) {
$opt{'X'} = $value;
}
+ elsif ($keyword =~ /OPT_K/) {
+ $opt{'K'} = $value;
+ }
+ elsif ($keyword =~ /OPT_N/) {
+ $opt{'N'} = $value;
+ }
elsif ($keyword =~ /OPT_C/) {
$opt{'C'} = 1;
}
@@ -555,7 +578,7 @@
exit(-1);
}
else {
- print DUMPARTICLE @{$body};
+ print DUMPARTICLE @{$body} or die "cannot print: $!";
close DUMPARTICLE;
}
}
@@ -790,7 +813,7 @@
}
binmode(FH);
seek(FH, $offset, 0);
- print FH $decoded;
+ print FH $decoded or die "cannot print: $!";
close(FH);
$log->debug("Finished decoding file.");
}
@@ -815,7 +838,7 @@
}
else {
binmode(FH);
- print FH $decoded;
+ print FH $decoded or die "cannot print: $!";
close(FH);
$log->info("Finished decoding.");
}
@@ -891,7 +914,7 @@
else {
binmode YENCTEMP;
foreach (@{$article}) {
- print YENCTEMP;
+ print YENCTEMP or die "cannot print: $!";
}
close YENCTEMP;
@@ -1134,11 +1157,12 @@
}
-sub process_single($$$$$) {
+sub process_single($$$$$$) {
my $servers = shift;
my $group = shift;
my $msgid = shift;
my $subject = shift;
+ my $authors = shift;
my $newfilename = shift;
my $log = get_logger("ubh::single");
@@ -1215,6 +1239,7 @@
$log->debug(" group = ", $group->{name});
$log->debug(" msgid = ", $msgid);
$log->debug(" subject = ", $subject);
+ $log->debug(" from = ", $authors);
my $metadata = Ubh::Metadata->new;
$metadata->article($server->{name}, $group->{name}, $articlenum);
@@ -1242,7 +1267,7 @@
my $mimefilename = $platform->get_tempfilename;
open(SINGFILE, "> ".$mimefilename)
or die "ERROR: open(".$mimefilename.") failed.\n";
- print SINGFILE @{$article};
+ print SINGFILE @{$article} or die "cannot print: $!";
close SINGFILE;
if ($opt{'D'}) {
@@ -1293,9 +1318,10 @@
}
-sub process_multipart($$$) {
+sub process_multipart($$$$) {
my $servers = shift;
my $group = shift;
+ my $authors = shift;
my $assemble_id = shift;
my $log = get_logger("ubh::multipart");
@@ -1341,6 +1367,7 @@
$log->info("Retrieving parts of multipart article:");
$log->debug(" group = ", $group->{name});
$log->info( " title = ", $title);
+ $log->debug(" from = ", $authors);
# Mark and sweep the assemble status to reserve it for this process
my $stmt =
@@ -1569,7 +1596,7 @@
# Part was successfully downloaded.
if ($opt{'A'}) {
- print PARTSFILE @{$p};
+ print PARTSFILE @{$p} or die "cannot print: $!";
}
else {
push(@parts, @{$p});
@@ -1722,7 +1749,7 @@
$log->info("Begin processing single part articles.");
my $stmt =
- "SELECT h.msgid, h.subject, h.category ".
+ "SELECT h.msgid, h.subject, h.authors, h.category ".
"FROM headers h, xref_headers x ".
"WHERE h.header_id = x.header_id ".
"AND x.newsgroup_id = ".$group->{newsgroup_id}." ".
@@ -1752,7 +1779,7 @@
$sth->execute;
while (my @cols = $sth->fetchrow_array) {
- my ($msgid, $subject, $category) = @cols;
+ my ($msgid, $subject, $authors, $category) = @cols;
my $title;
if (!$opt{'g'}) {
@@ -1790,6 +1817,20 @@
next;
}
+ # Inclusion/exclusion filtering.
+ # Skip authors that don't match the inclusion filter.
+ # Skip authors that do match the exclusion filter.
+ if ((defined $opt{'K'} && $authors !~ /$opt{'K'}/o) ||
+ (defined $opt{'N'} && $authors =~ /$opt{'N'}/o)) {
+
+ # It was either not included or was excluded.
+ if ($opt{'z'}) {
+ $dbh->do(
+ "UPDATE headers SET status = 'READ' ".
+ "WHERE msgid = ".$dbh->quote($msgid));
+ }
+ next;
+ }
# Skip it if there is a batch file and it isn't mentioned.
next if (defined $batchfile && !$batchfile->contains($title));
@@ -1827,6 +1868,7 @@
$group,
$msgid,
$subject,
+ $authors,
$newfilename);
}
}
@@ -1837,7 +1879,7 @@
$log->info("Begin processing multipart articles.");
my $stmt =
- "SELECT a.assemble_id, h.msgid, h.subject, h.category ".
+ "SELECT a.assemble_id, h.msgid, h.subject, h.authors, h.category ".
"FROM assemble a, headers h, xref_headers x ".
"WHERE a.assemble_id = x.assemble_id ".
"AND h.header_id = x.header_id ".
@@ -1863,7 +1905,7 @@
$sth->execute;
while (my @cols = $sth->fetchrow_array) {
- my ($assemble_id, $msgid, $subject, $category) = @cols;
+ my ($assemble_id, $msgid, $subject, $authors, $category) = @cols;
# Try to pick a title out of the subject using filename extension filter.
my $title;
@@ -1898,6 +1940,21 @@
next;
}
+ # Inclusion/exclusion filtering.
+ # Skip authors that don't match the inclusion filter.
+ # Skip authors that do match the exclusion filter.
+ if ((defined $opt{'K'} && $authors !~ /$opt{'K'}/o) ||
+ (defined $opt{'N'} && $authors =~ /$opt{'N'}/o)) {
+
+ # It was either not included or was excluded.
+ if ($opt{'z'}) {
+ $dbh->do(
+ "UPDATE headers SET status = 'READ' ".
+ "WHERE msgid = ".$dbh->quote($msgid));
+ }
+ next;
+ }
+
# Skip it if there is a batch file and it isn't mentioned.
next if (defined $batchfile && !$batchfile->contains($title));
@@ -1921,6 +1978,7 @@
process_multipart(
$servers,
$group,
+ $authors,
$assemble_id);
}
}
@@ -1969,7 +2027,7 @@
=head1 SYNOPSIS
-ubh [-c file] [(-S|-M)] [-A] [-b file] [-C] [-d] [-D] [-g] [-a] [(-I|-X) pattern] [-L] [-O (yes|no|skip)] [-u] [-w] [-y] [-z]
+ubh [-c file] [(-S|-M)] [-A] [-b file] [-C] [-d] [-D] [-g] [-a] [(-I|-X) pattern] [(-K|-N) pattern] [-L] [-O (yes|no|skip)] [-u] [-w] [-y] [-z]
=head1 DESCRIPTION
@@ -2024,6 +2082,7 @@
C<ubhcatalog>), one per line, to be downloaded.
Mutually exclusive with B<-I> and B<-X>.
+Mutually exclusive with B<-K> and B<-N>.
=item -d
@@ -2075,12 +2134,22 @@
=item -I I<regexp>
-Inclusion search filter (double quote on command line).
+Inclusion search filter for Subject field (double quote on command line).
+I<regexp> is any valid Perl regular expression.
+
+=item -K I<regexp>
+
+Inclusion search filter for From field (double quote on command line).
I<regexp> is any valid Perl regular expression.
=item -X I<regexp>
-Exclusion search filter (double quote on command line).
+Exclusion search filter for Subject field (double quote on command line).
+I<regexp> is any valid Perl regular expression.
+
+=item -N I<regexp>
+
+Exclusion search filter for From field (double quote on command line).
I<regexp> is any valid Perl regular expression.
=item -C