annotate translate.pl @ 10:14a966369278

working version of exporting bugs from bugzilla in tj3 format (without bookings)
author cin
date Mon, 07 Sep 2015 01:37:11 +0300
parents cc7244ab1b9f
children 4eb9fdf4efa9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8cae44c166d3 initial xslt and sample xml
cin
parents:
diff changeset
1 #!/usr/bin/perl -w
8cae44c166d3 initial xslt and sample xml
cin
parents:
diff changeset
2
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
3 use IMPL::require {
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
4 BzClient => 'Benzin::Bugzilla::XmlRpcClient',
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
5 BugWriter => 'Benzin::Bugzilla::XmlWriter'
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
6 };
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
7 use YAML::XS qw(LoadFile Dump);
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
8 use XML::Writer;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
9 use IPC::Run qw(start finish);
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
10
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
11 my $config = LoadFile("config.yaml");
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
12
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
13 if ( !( $config->{bugzilla}{url} =~ /\/$/ ) ) {
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
14 $config->{bugzilla}{url} .= "/";
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
15 }
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
16
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
17 my $bz = BzClient->new(
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
18 url => $config->{bugzilla}{url},
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
19 apikey => $config->{bugzilla}{apikey}
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
20 );
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
21
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
22 my $bugs = $config->{bugzilla}{bugs} or die "No bugs specified";
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
23 $bugs = [$bugs] unless ref $bugs eq 'ARRAY';
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
24
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
25 local (*HIN);
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
26
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
27 my $proc = start(
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
28 [ 'saxon8', '-novw', '-', 'bug-list.xsl' ],
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
29 #[ 'cat' ],
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
30 '<pipe', \*HIN, '>', \*STDOUT
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
31 ) or die "failed to create pipe: $!";
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
32
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
33 binmode *HIN, ":encoding(utf-8)";
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
34 my $writer =
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
35 BugWriter->new( OUTPUT => *HIN, DATA_INDENT => 2, DATA_MODE => 'on' );
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
36
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
37 eval {
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
38 my %visited;
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
39
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
40 my $fetched = $bz->GetBugsHierarchy( { ids => [283] } );
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
41
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
42 $bz->PopulateBugsComments($fetched);
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
43 $bz->PopulateBugsHistory($fetched);
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
44
10
14a966369278 working version of exporting bugs from bugzilla in tj3 format (without bookings)
cin
parents: 9
diff changeset
45 $writer->WriteBugList($fetched);
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
46
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
47 };
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
48 warn Dump($@) and die $@ if $@;
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
49
6
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
50 close HIN;
2a5f38eb25a9 migrated to saxon8 as xslt processor
cin
parents: 5
diff changeset
51 finish($proc);
5
d2efec56373f working buglist transform and bugs fetching
cin
parents: 1
diff changeset
52
9
cc7244ab1b9f implemented time reports on bugs
cin
parents: 7
diff changeset
53 1;