rev 9270 - in people/modax/copyright-helper/trunk: . licenses
Modestas Vainius
modax-guest at alioth.debian.org
Mon Feb 4 12:06:56 UTC 2008
Author: modax-guest
Date: 2008-02-04 12:06:55 +0000 (Mon, 04 Feb 2008)
New Revision: 9270
Modified:
people/modax/copyright-helper/trunk/CHCopyright.pm
people/modax/copyright-helper/trunk/CHCore.pm
people/modax/copyright-helper/trunk/CHLicenses.pm
people/modax/copyright-helper/trunk/copyright-helper.pl
people/modax/copyright-helper/trunk/licenses/gnugpl.pm
Log:
* v0.3.1
* Produces more RFC822-ish output. Some fields based on
http://wiki.debian.org/Proposals/CopyrightFormat
Modified: people/modax/copyright-helper/trunk/CHCopyright.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHCopyright.pm 2008-02-04 11:13:32 UTC (rev 9269)
+++ people/modax/copyright-helper/trunk/CHCopyright.pm 2008-02-04 12:06:55 UTC (rev 9270)
@@ -267,10 +267,11 @@
sub CHCopyright::Author::toString($) {
my ($self) = @_;
+ my $years = (@{$self->{years}}) ? (" " . $self->getAllYears()) : "";
if ($self->getEmail()) {
- return sprintf "Copyright ©: %s <%s> %s", $self->getFullName(), $self->getEmail() , $self->getAllYears();
+ return sprintf("©%s %s <%s>", $years, $self->getFullName(), $self->getEmail());
} else {
- return sprintf "Copyright ©: %s %s", $self->getFullName(), $self->getAllYears();
+ return sprintf("©%s %s", $years, $self->getFullName());
}
}
Modified: people/modax/copyright-helper/trunk/CHCore.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHCore.pm 2008-02-04 11:13:32 UTC (rev 9269)
+++ people/modax/copyright-helper/trunk/CHCore.pm 2008-02-04 12:06:55 UTC (rev 9270)
@@ -152,48 +152,68 @@
return (@{$self->{copyrights}} || $self->{license});
}
-sub CHCore::File::printDepth($) {
- print " " x (shift()->getDepth() * 4);
+sub CHCore::File::toStringDepth($) {
+ return " " x (shift()->getDepth() * 4);
}
-sub CHCore::File::printCopyrights($) {
+sub __COPYRIGHT_INDENT {
+ ' '; # " " x length("Copyright: ")
+}
+
+sub CHCore::File::toStringCopyrights($) {
my $self = shift;
my $copyrights = $self->{copyrights};
- for my $cr (@$copyrights) {
- $self->printDepth();
- print " ", $cr->toString(), $self->isInheritedStr("copyrights"), "\n";
+ my $str .= "Copyright: ";
+
+ if (@$copyrights) {
+ my $needsIndent = 0;
+ for my $cr (@$copyrights) {
+ if ($needsIndent) {
+ $str .= __COPYRIGHT_INDENT;
+ } else {
+ $needsIndent = 1;
+ }
+ $str .= $cr->toString() . $self->isInheritedStr("copyrights") . "\n";
+ }
+ return $str;
+ } else {
+ return "";
}
}
-sub CHCore::File::printLicense($) {
+sub CHCore::File::toStringLicense($) {
my $self = shift;
my $license = $self->{license};
if ($license && $license->isValid()) {
- $self->printDepth();
- print " License: ", $license->getFullLicenseString(), $self->isInheritedStr("license"), "\n";
+ my $str = "License: " . $license->getID() . $self->isInheritedStr("license") . "\n";
# my @text = $license->getNiceFoundInText(68);
# for my $t (@text) {
# $self->printDepth();
# print " # ", $t, "\n";
# }
+ return $str;
+ } else {
+ return "";
}
+
}
sub CHCore::File::printAll($) {
my $self = shift;
- $self->printDepth();
+# $self->printDepth();
if ($self->isDirectory()) {
- print "+++ ", $self->getFilename(), "/: ";
+ print "Directory: ", $self->getPathWithoutRoot(), "/";
} else {
- print $self->getFilename(), ": ";
+ print "Files: ", $self->getPathWithoutRoot();
}
+ print "\n";
if ($self->isParsed()) {
+ print $self->toStringCopyrights();
+ print $self->toStringLicense();
print "\n";
- $self->printCopyrights();
- $self->printLicense();
} else {
- print "-\n";
+ print " Copyright and license information not available or not applicable";
}
}
@@ -689,40 +709,46 @@
sub CHCore::CopyrightSummary::toString($) {
my $self = shift;
- my $str = "Copyright © " . $self->getKeyName() . ":\n";
+ my $str = "Copyright: © " . $self->getKeyName();
+ my $emails = $self->getEmails();
+
+ # If there is only one email address
+ if (scalar(@$emails) == 1) {
+ $str .= " <" . $$emails[0] . ">";
+ }
+ $str .= "\n";
- $str .= sprintf(" Credited %d time%s;\n", $self->getTimesCredited(), ($self->getTimesCredited() == 1) ? "" : "s");
+ $str .= sprintf("Credited: %d time%s;\n", $self->getTimesCredited(), ($self->getTimesCredited() == 1) ? "" : "s");
# Alternative names
my $names = $self->getNames();
if (scalar(@$names) > 1) {
- $str .= sprintf(" Other name%s: ", (scalar(@$names) > 2) ? "s" : "");
+ $str .= "Other-Names: ";
my $key = $self->getKeyName();
for my $n (@$names) {
$str .= "$n, " if ($key ne $n);
}
- $str = substr($str, 0, -2) . ";\n";
+ $str = substr($str, 0, -2) . "\n";
}
# Emails
- my $emails = $self->getEmails();
- if (@$emails) {
- $str .= sprintf(" Email address%s: ", (scalar(@$emails) > 1) ? "es" : "");
+ if (scalar(@$emails) > 1) {
+ $str .= "Email-Addresses: ";
for my $email (@$emails) {
$str .= "<${email}>, ";
}
- $str = substr($str, 0, -2) . ";\n";
+ $str = substr($str, 0, -2) . "\n";
}
# Years
my $years = $self->getYears();
if (@$years) {
- $str .= " Years: ";
+ $str .= "Years: ";
for my $y (@$years) {
$str .= "$y, ";
}
}
- $str = substr($str, 0, -2) . ";";
+ $str = substr($str, 0, -2) . "\n";
return $str;
}
@@ -739,28 +765,26 @@
sub CHCore::CopyrightSummary::toStringFiles {
my ($self, $desc_indent, $file_indent) = @_;
+ my ($dindent, $findent) =
+ __handle_indent_args($desc_indent, $file_indent);
- $desc_indent = 0 unless defined $desc_indent;
- $file_indent = $desc_indent + 2 unless defined $file_indent;
-
my $files = $self->getFiles();
- my $tindent = " " x $desc_indent;
- my $str = $tindent . sprintf("Copyrighted file%s (%d):\n", (scalar(@$files) > 1) ? "s" : "", scalar(@$files));
+ my $str = "";
+
+ if (scalar(@$files) > 1) {
+ $str .= $dindent . sprintf("Copyrighted-Files-Count: %d\n", scalar(@$files));
+ }
+ $str .= $dindent . "Copyrighted-Files:\n";
+ $str .= $findent . join ("\n$findent", map $_->getPathWithoutRoot(), @$files);
- $tindent = " " x $file_indent;
- $str .= $tindent . join ("\n$tindent", map $_->getPathWithoutRoot(), @$files);
-
return $str;
}
sub CHCore::CopyrightSummary::toStringLicenses {
my ($self, $desc_indent, $lic_indent) = @_;
+ my ($dindent, $lindent) =
+ __handle_indent_args($desc_indent, $lic_indent);
- $desc_indent = 0 unless defined $desc_indent;
- $lic_indent = $desc_indent + 2 unless defined $lic_indent;
- my $dindent = " " x $desc_indent;
- my $lindent = " " x $lic_indent;
-
my $summary = new CHCore::LicenseSummary;
$summary->addFiles($self->getFiles());
@@ -768,8 +792,11 @@
my $impl = scalar(@{$summary->getImplicit()});
my $expl = scalar(@{$summary->getExplicit()});
- my $str = $dindent . sprintf("Used license%s (%d):\n", ($count > 1) ? "s" : "", $count);
- $str .= $lindent . join ("\n$lindent", map $_->getID(), @{$summary->getLicenses()});
+ my $str = "";
+ if ($count > 1) {
+ $str .= $dindent . sprintf("Used-Licenses-Count: %d\n", $count);
+ }
+ $str .= $dindent . "Used-Licenses: " . join (", ", map $_->getID(), @{$summary->getLicenses()}) . "\n";
return $str;
} else {
Modified: people/modax/copyright-helper/trunk/CHLicenses.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHLicenses.pm 2008-02-04 11:13:32 UTC (rev 9269)
+++ people/modax/copyright-helper/trunk/CHLicenses.pm 2008-02-04 12:06:55 UTC (rev 9270)
@@ -76,25 +76,26 @@
return bless($self, $_[0]);
}
-sub CHLicenses::LicenseBase::getShortLicenseName($) {
+sub CHLicenses::LicenseBase::getShortName($) {
return "Short license name not specified";
}
-sub CHLicenses::LicenseBase::getLongLicenseName($) {
+sub CHLicenses::LicenseBase::getLongName($) {
return "Long license name not specified";
}
-sub CHLicenses::LicenseBase::formatVersion($$) {
- my ($self, $verPrefix) = @_;
+sub CHLicenses::LicenseBase::formatVersion($$$) {
+ my ($self, $verPrefix, $verAnyStr) = @_;
+ $verAnyStr = "" unless defined($verAnyStr);
my $ver = $self->getVersion();
- return ($ver > 0) ? "${verPrefix}${ver}" : "";
+ return ($ver > 0) ? "${verPrefix}${ver}" : $verAnyStr
}
sub CHLicenses::LicenseBase::getID($) {
my ($self) = @_;
- my $str = sprintf("%s %s", $self->getLongName(), $self->formatVersion("v"));
+ my $str = sprintf("%s-%s", $self->getShortName(), $self->formatVersion("", "any"));
if ($self->isLater()) {
- return $str . " or later";
+ return $str . "+";
} else {
return $str;
}
@@ -102,7 +103,7 @@
sub CHLicenses::LicenseBase::getFullLicenseString($) {
my ($self) = @_;
- my $str = sprintf("%s %s", $self->getLongName(), $self->formatVersion("version "));
+ my $str = sprintf("%s%s", $self->getLongName(), $self->formatVersion(", version "));
if ($self->isLater()) {
return $str . " or later";
} else {
Modified: people/modax/copyright-helper/trunk/copyright-helper.pl
===================================================================
--- people/modax/copyright-helper/trunk/copyright-helper.pl 2008-02-04 11:13:32 UTC (rev 9269)
+++ people/modax/copyright-helper/trunk/copyright-helper.pl 2008-02-04 12:06:55 UTC (rev 9270)
@@ -119,9 +119,9 @@
my @summaries = sort { -($a->getTimesCredited() <=> $b->getTimesCredited()) } @$summaries;
for my $summary (@summaries) {
$summary->cleanup();
- print $summary->toString(), "\n";
- print $summary->toStringLicenses(2), "\n";
- print $summary->toStringFiles(2);
+ print $summary->toString();
+ print $summary->toStringLicenses();
+ print $summary->toStringFiles();
print "\n\n";
}
}
@@ -178,7 +178,7 @@
}
# Entry point
-${main::VERSION}='0.3';
+${main::VERSION}='0.3.1';
print_msg "\n";
print_msg "Copyright Helper v${main::VERSION}\n";
print_msg "Extracts copyright and license information from source code\n\n";
Modified: people/modax/copyright-helper/trunk/licenses/gnugpl.pm
===================================================================
--- people/modax/copyright-helper/trunk/licenses/gnugpl.pm 2008-02-04 11:13:32 UTC (rev 9269)
+++ people/modax/copyright-helper/trunk/licenses/gnugpl.pm 2008-02-04 12:06:55 UTC (rev 9270)
@@ -28,16 +28,16 @@
# (at your option) any later version.
if ($p =~ m/redistribute.*modify.*GNU General Public License as published(.*)$/) {
my $version = $1;
+ my $license = new CHLicenses::gnugpl;
+
# Check for version and later clause (optional)
- if ($version =~ m/version ([\d.]*[\d]+) of the License(.*)$/) {
- my $license = new CHLicenses::gnugpl;
+ if ($version =~ m/version ([\d.]*[\d]+) of the License(.*)$/i) {
$license->{"version"} = $1;
$version = $2;
$license->{"later"} = 1 if ($version =~ m/any later version/);
- $license->{"foundInText"} = $p;
-
- return $license;
}
+ $license->{"foundInText"} = $p;
+ return $license;
}
}
return 0;
@@ -81,7 +81,7 @@
}
sub getShortName($) {
- "GNU GPL";
+ "GPL";
}
sub getLongName($) {
More information about the pkg-kde-commits
mailing list