[SCM] Debian package checker branch, master, updated. 2.2.18-33-g3cfd89c
The following commit has been merged in the master branch:
commit faade6283abac8d18cc05e25793f761a0ca83f76
Author: Russ Allbery <rra@debian.org>
Date: Wed Dec 23 20:42:26 2009 -0800
Rewrite experimental XML output to be more maintainable
* lib/Lintian/Output/XML.pm:
+ [RA] Rewrite to be more readable and fix the tags attribute for
overridden experimental tags.
diff --git a/debian/changelog b/debian/changelog
index 770e010..19a071a 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,9 @@ lintian (2.3.0) UNRELEASED; urgency=low
+ [RA] Adjust for the renaming of pkg in the file information hash.
* lib/Lintian/Output/*.pm:
+ [RA] Adjust for print_tag() and file information hash changes.
+ * lib/Lintian/Output/XML.pm:
+ + [RA] Rewrite to be more readable and fix the tags attribute for
+ overridden experimental tags.
* lib/Lintian/Tag/Info.pm:
+ [RA] Add a code method that returns the tag code corresponding to
the severity and certainty for a tag, based on get_tag_code from
diff --git a/lib/Lintian/Output/XML.pm b/lib/Lintian/Output/XML.pm
index c113385..d45091a 100644
--- a/lib/Lintian/Output/XML.pm
+++ b/lib/Lintian/Output/XML.pm
@@ -17,6 +17,7 @@
# MA 02110-1301, USA.
package Lintian::Output::XML;
+
use strict;
use warnings;
@@ -27,28 +28,31 @@ use base qw(Lintian::Output);
sub print_tag {
my ($self, $pkg_info, $tag_info, $information, $overridden) = @_;
-
$self->issued_tag($tag_info->tag);
- $self->_print_xml('',
- qq{<tag severity="}, $tag_info->severity, qq{" certainty="}, $tag_info->certainty, qq{"},
- 'flags="'.($tag_info->experimental ? 'experimental' : ''),
- ($overridden ? 'overridden' : '').'"',
- qq{name="}, $tag_info->tag, qq{">}.encode_entities("$information","<>&\"'").qq{</tag>},
- );
+ my $flags = ($tag_info->experimental ? 'experimental' : '');
+ if ($overridden) {
+ $flags .= ',' if $flags;
+ $flags .= 'overridden';
+ }
+ my @attrs = ([ severity => $tag_info->severity ],
+ [ certainty => $tag_info->certainty ],
+ [ flags => $flags ],
+ [ name => $tag_info->tag ]);
+ $self->_print_xml_tag('tag', \@attrs, $information);
}
sub print_start_pkg {
my ($self, $pkg_info) = @_;
-
- $self->_print_xml('',
- qq{<package type="$pkg_info->{type}" name="$pkg_info->{package}"},
- qq{architecture="$pkg_info->{arch}" version="$pkg_info->{version}">}
- );
+ my @attrs = ([ type => $pkg_info->{type} ],
+ [ name => $pkg_info->{package} ],
+ [ architecture => $pkg_info->{arch} ],
+ [ version => $pkg_info->{version} ]);
+ $self->_print_xml_tag('package', \@attrs);
}
sub print_end_pkg {
my ($self) = @_;
- $self->_print_xml('', '</package>');
+ print { $self->stdout } "</package>\n"
}
sub _delimiter {
@@ -58,17 +62,24 @@ sub _delimiter {
sub _print {
my ($self, $stream, $lead, @args) = @_;
$stream ||= $self->stderr;
-
my $output = $self->string($lead, @args);
- print {$stream} $output;
+ print { $stream } $output;
}
-sub _print_xml {
- my ($self, $stream, @args) = @_;
- $stream ||= $self->stdout;
-
- print {$stream} join(' ',@args), "\n";
+# Print a given XML tag to standard output. Takes the tag, an anonymous array
+# of pairs of attributes and values, and then the contents of the tag.
+sub _print_xml_tag {
+ my ($self, $tag, $attrs, $content) = @_;
+ my $output = "<$tag";
+ for my $attr (@$attrs) {
+ my ($name, $value) = @$attr;
+ $output .= " $name=" . '"' . $value . '"';
+ }
+ $output .= '>';
+ if (defined $content) {
+ $output .= encode_entities($content,"<>&\"'") . "</$tag>";
+ }
+ print { $self->stdout } $output, "\n";
}
1;
-
--
Debian package checker
Reply to: