File: munge-data

package info (click to toggle)
inn2 2.4.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,912 kB
  • ctags: 7,860
  • sloc: ansic: 85,104; perl: 11,427; sh: 9,863; makefile: 2,498; yacc: 1,563; python: 298; lex: 252; tcl: 7
file content (43 lines) | stat: -rwxr-xr-x 1,675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

##  $Id: munge-data 5144 2002-02-24 06:24:55Z rra $
##
##  Munge .overview data into something suitable for test data.
##
##  This script isn't used regularly and is here only for the use of INN
##  developers and other people needing to generate more overview test data.
##  It expects overview data but possibly with extra fields at the end, snips
##  off To: data (to avoid putting people's e-mail addresses into INN test
##  data), and if Newsgroups: data is present, rewrites the Xref header to use
##  it instead of keeping the Xref data (this is so that I can use .overview
##  files from Gnus as test data).  It generates overview data but with the
##  newsgroup name and a colon prepended to the article number so that it can
##  be split apart into overview data for multiple groups.
##
##  Please don't include overview information for people's articles into INN's
##  test suite without their permission.

my %number;
while (<>) {
    s/\s+$//;
    my @data = split /\t/;
    @data = grep { !/^To:/ } @data;
    my $group = pop @data;
    my $xref = pop @data;
    if ($group =~ s/^Newsgroups: //) {
        my @groups = split (/\s*,\s*/, $group);
        for (@groups) {
            $number{$_} = 1 unless $number{$_};
            $data[0] = $_ . ':' . $number{$_}++;
            $number{$_} += int (rand 5) if rand (10) > 8;
            print join ("\t", @data, "Xref: inn.example.com $data[0]"), "\n";
        }
    } else {
        $xref =~ s/Xref:\s*\S+\s+//;
        my @xref = split (' ', $xref);
        for (@xref) {
            $data[0] = $_;
            print join ("\t", @data, "Xref: inn.example.com $xref"), "\n";
        }
    }
}