rev 13541 - people/modax/copyright-helper/trunk
Modestas Vainius
modax-guest at alioth.debian.org
Sun Jan 25 16:25:04 UTC 2009
Author: modax-guest
Date: 2009-01-25 16:25:04 +0000 (Sun, 25 Jan 2009)
New Revision: 13541
Modified:
people/modax/copyright-helper/trunk/CHCore.pm
Log:
Fixes for handling directories without licensing information
Modified: people/modax/copyright-helper/trunk/CHCore.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHCore.pm 2009-01-25 16:00:05 UTC (rev 13540)
+++ people/modax/copyright-helper/trunk/CHCore.pm 2009-01-25 16:25:04 UTC (rev 13541)
@@ -473,8 +473,11 @@
my $dir = $f->getDirectory();
if ($dir) {
$dir = $dir->getPathWithoutRoot();
+ } elsif (!$f->isDirectory()) {
+ # Omit scan root directory from the list
+ $dir = "/";
} else {
- $dir = "/";
+ next;
}
push @{$dirs{$dir}}, $f;
}
@@ -989,8 +992,11 @@
sub CHCore::LicenseSummary::__toStringLicense($$) {
my ($self, $lic, $files, $i_lvl1, $i_lvl2, $msg) = @_;
my $str = "--\n";
- $str .= $i_lvl1 . $lic->getFullLicenseString() .
- " (" . $lic->getID() . ")\n";
+
+ if (defined $lic) {
+ $str .= $i_lvl1 . $lic->getFullLicenseString() .
+ " (" . $lic->getID() . ")\n";
+ }
my $print_routine = sub {
my ($action, $f) = @_;
@@ -1013,16 +1019,28 @@
}
};
if (@$files) {
- $str .= $i_lvl2;
- if (defined($msg) && $msg eq "implicit") {
- $str .= sprintf("However, the license of %d file(s) was not explicitly specified:\n\n",
- scalar(@$files));
+ if (defined $msg) {
+ $str .= $i_lvl2;
+ if ($msg eq "implicit") {
+ $msg = "However, the license of %d files was not explicitly specified:\n\n";
+ $msg = "However, the license was not explicitly specified for the following file:\n\n"
+ if (scalar(@$files) == 1);
+ $str .= sprintf($msg, scalar(@$files));
+ } elsif ($msg eq "licensed") {
+ $msg = "%d files are licensed under this license:\n\n";
+ $msg = "The following file is licensed under this license:\n\n" if (scalar(@$files) == 1);
+ $str .= sprintf($msg, scalar(@$files));
+ } else {
+ $str .= "\n";
+ }
} else {
- $str .= sprintf("%d file(s) are licensed under this license:\n\n", scalar(@$files));
+ $str .= "\n";
}
CHCore::Directory::wildcardize($print_routine, $files, 1);
}
- $str .= "\n" . $lic->getLicenseTerms($i_lvl1) . "\n--\n";
+ if (defined $lic) {
+ $str .= "\n" . $lic->getLicenseTerms($i_lvl1) . "\n--\n";
+ }
return $str;
}
@@ -1034,7 +1052,12 @@
my $maxfiles = [];
my $str = "";
- if ($self->getLicenseCount() == 1) {
+ if ($self->getLicenseCount() == 0) {
+ my $files = $self->{unknown_licenses};
+ $str .= $i_lvl1 . "Licensing information is not explicitly available for the files below:\n";
+ $str .= $self->__toStringLicense(undef, $files, $i_lvl2, $i_lvl3);
+ return $str;
+ } elsif ($self->getLicenseCount() == 1) {
my @values = values(%{$self->{licenses}});
my $lic_array = $values[0];
$maxlic = $lic_array->[0];
@@ -1067,7 +1090,7 @@
my $lic = $lic_array->[0];
my $files = $lic_array->[1];
if (!$lic->equals($maxlic)) {
- $str .= $self->__toStringLicense($lic, $files, $i_lvl2, $i_lvl3) . "\n";
+ $str .= $self->__toStringLicense($lic, $files, $i_lvl2, $i_lvl3, "licensed") . "\n";
}
}
return $str;
More information about the pkg-kde-commits
mailing list