author | Dario Sestito <darios@symbian.org> |
Mon, 07 Jun 2010 12:44:01 +0100 | |
changeset 254 | e7df00ade863 |
parent 245 | 478794dc0351 |
permissions | -rw-r--r-- |
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
1 |
#! perl -w |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
2 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
3 |
# Copyright (c) 2009 Symbian Foundation Ltd |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
4 |
# This component and the accompanying materials are made available |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
6 |
# which accompanies this distribution, and is available |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
8 |
# |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
9 |
# Initial Contributors: |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
10 |
# Symbian Foundation Ltd - initial contribution. |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
11 |
# |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
12 |
# Contributors: |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
13 |
# |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
14 |
# Description: |
245
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
15 |
# Convert comma-separated buglist into Mediawiki table |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
16 |
# |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
17 |
# Usage |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
18 |
# buglist_to_mediawiki bugreport.csv [--pdk=PDK_3.0.0] > bugs.mediawiki.txt |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
19 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
20 |
use strict; |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
21 |
|
244
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
22 |
use FindBin; |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
23 |
use lib "$FindBin::Bin\\..\\lib"; |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
24 |
use Text::CSV; |
245
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
25 |
use Getopt::Long; |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
26 |
|
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
27 |
my $PDK="PDK_???"; |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
28 |
|
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
29 |
GetOptions(( |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
30 |
'pdk=s' => \$PDK, |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
31 |
)); |
244
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
32 |
|
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
33 |
my $csv = Text::CSV->new(); |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
34 |
|
245
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
35 |
print "== Defects open at time of creation of $PDK ==\n\n"; |
478794dc0351
Added output of Heading above table, so the script generates all of the desired content for the wiki page, not just part of it.
Simon Howkins <simonh@symbian.org>
parents:
244
diff
changeset
|
36 |
|
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
37 |
print "{|\n"; # start of table |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
38 |
|
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
39 |
while (my $line = <>) |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
40 |
{ |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
41 |
chomp $line; |
244
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
42 |
|
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
43 |
unless ($csv->parse($line)) |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
44 |
{ |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
45 |
my $err = $csv->error_input(); |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
46 |
warn "Failed to parse line '$line': $err\n"; |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
47 |
next; |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
48 |
} |
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
49 |
|
2251fde91223
Changed script to use CSV formatted input, rather than TSV.
Simon Howkins <simonh@symbian.org>
parents:
239
diff
changeset
|
50 |
my @columns = $csv->fields(); |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
51 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
52 |
next if scalar @columns < 2; # skip dubious looking lines |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
53 |
|
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
54 |
if ($. == 1) |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
55 |
{ |
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
56 |
# First line of file = table headings |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
57 |
my %preferredHeadings = |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
58 |
( |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
59 |
bug_id => "ID", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
60 |
bug_severity => "Severity", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
61 |
reporter => "Reporter", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
62 |
bug_status => "Status", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
63 |
product => "Package", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
64 |
short_desc => "Title", |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
65 |
); |
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
66 |
@columns = map { $preferredHeadings{$_} || $_ } @columns; |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
67 |
print "! ", join(" !! ", @columns), "\n"; |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
68 |
next; |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
69 |
} |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
70 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
71 |
# row with a bug id |
239
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
72 |
|
d01a4084d621
Extended to put the preferred column headings into the table.
Simon Howkins <simonh@symbian.org>
parents:
20
diff
changeset
|
73 |
$columns[0] = "[http://developer.symbian.org/bugs/show_bug.cgi?id=$columns[0] Bug$columns[0]]"; |
20
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
74 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
75 |
print "|-\n"; # row separator |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
76 |
print "| ", join(" || ", @columns), "\n"; |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
77 |
} |
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
78 |
|
36e05c0da8f7
Trivial script to convert a "copied" bugzilla bug listing into a Mediawiki table
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
79 |
print "|}\n"; |