rev 13514 - in people/modax/copyright-helper/trunk: . licenses

Modestas Vainius modax-guest at alioth.debian.org
Sat Jan 24 23:26:53 UTC 2009


Author: modax-guest
Date: 2009-01-24 23:26:52 +0000 (Sat, 24 Jan 2009)
New Revision: 13514

Added:
   people/modax/copyright-helper/trunk/licenses/bsd.pm
Modified:
   people/modax/copyright-helper/trunk/CHLicenses.pm
   people/modax/copyright-helper/trunk/copyright-helper.pl
Log:
Add support for BSD style licenses

Modified: people/modax/copyright-helper/trunk/CHLicenses.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHLicenses.pm	2009-01-24 23:01:12 UTC (rev 13513)
+++ people/modax/copyright-helper/trunk/CHLicenses.pm	2009-01-24 23:26:52 UTC (rev 13514)
@@ -91,21 +91,29 @@
 
 sub CHLicenses::LicenseBase::getID($) {
     my ($self) = @_;
-    my $str = sprintf("%s-%s", $self->getShortName(), $self->formatVersion("", "any"));
-    if ($self->isLater()) {
-        return $str . "+";
+    if (defined($self->{version}) && $self->{version} eq "") {
+        return $self->getShortName();
     } else {
-        return $str;
+        my $str = sprintf("%s-%s", $self->getShortName(), $self->formatVersion("", "any"));
+        if ($self->isLater()) {
+            return $str . "+";
+        } else {
+            return $str;
+        }
     }
 }
 
 sub CHLicenses::LicenseBase::getFullLicenseString($) {
     my ($self) = @_;
-    my $str = sprintf("%s%s", $self->getLongName(), $self->formatVersion(", version "));
-    if ($self->isLater()) {
-        return $str . " or later";
+    if (defined($self->{version}) && $self->{version} eq "") {
+        return $self->getLongName();
     } else {
-        return $str;
+        my $str = sprintf("%s%s", $self->getLongName(), $self->formatVersion(", version "));
+        if ($self->isLater()) {
+            return $str . " or later";
+        } else {
+            return $str;
+        }
     }
 }
 

Modified: people/modax/copyright-helper/trunk/copyright-helper.pl
===================================================================
--- people/modax/copyright-helper/trunk/copyright-helper.pl	2009-01-24 23:01:12 UTC (rev 13513)
+++ people/modax/copyright-helper/trunk/copyright-helper.pl	2009-01-24 23:26:52 UTC (rev 13514)
@@ -221,7 +221,7 @@
 }
 
 # Entry point
-${main::VERSION}='0.4.9';
+${main::VERSION}='0.5.0';
 print_msg "\n";
 print_msg "Copyright Helper v${main::VERSION}\n";
 print_msg "Extracts copyright and license information from source code\n\n";

Added: people/modax/copyright-helper/trunk/licenses/bsd.pm
===================================================================
--- people/modax/copyright-helper/trunk/licenses/bsd.pm	                        (rev 0)
+++ people/modax/copyright-helper/trunk/licenses/bsd.pm	2009-01-24 23:26:52 UTC (rev 13514)
@@ -0,0 +1,122 @@
+# Copyright (C) 2008 Modestas Vainius <modestas at vainius.eu>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>
+
+package CHLicenses::bsd;
+use strict;
+use CHLicenses;
+our @ISA = qw( CHLicenses::LicenseBase );
+
+# Preamle is usually like:
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+
+# Advertising clause (BAD)
+
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+
+my $P1_RE = qr/\bRedistribution\b.*\bsource\b.*\bbinary\b.*\bwith\b.*\bwithout\b.*\bmodification\b.*\bpermitted\b.*\bprovided\b.*conditions?\b.*\bmet\b/is;
+my $P2_RE = qr/\bRedistributions?\b.*\bsource\W+code\b.*\bmust\b.*\bretain\b.*\bcopyright\b.*\bnotice\b.*\bconditions\b/is;
+my $P3_RE = qr/\bRedistributions?\b.*\bbinary\b.*\bmust\b.*\bcopyright\b.*\bnotice\b.*\bconditions\b.*\bdisclaimer\b.*\bdocumentation\b.*\bdistribution/is;
+my $P4_RE = qr/\bNeither\b.*\bname\b.*\bendorse\b.*\bpromote\b.*\bproducts\b.*\bwritten\b.*\bpermissions?\b/is;
+my $ADV_RE = qr/\badvertising\b.*\bfeatures\b.*\bmust\b.*\bdisplay\b.*\backnowledge.*\bpermissions?\b/is;
+
+sub matchCopyrightedFile($\@) {
+    my ($self, $text) = @_;
+    my $advertising;
+    my $score = 0;
+    my $foundInText = "";
+    my ($p1, $p2, $p3, $p4);
+    for my $p (@$text) {
+        my $foundhere;
+
+        if (!$p1 && $p =~ $P1_RE) {
+            $score += 2;
+            $foundhere = 1;
+            $p1 = 1;
+#            print STDERR "score 1:", $score, "\n";
+        }
+        if (!$p2 && $p =~ $P2_RE) {
+            $score += 3;
+            $foundhere = 1;
+            $p2 = 1;
+#            print STDERR "score 2:", $score, "\n";
+        }
+        if (!$p3 && $p =~ $P3_RE) {
+            $score += 3;
+            $foundhere = 1;
+            $p3 = 1;
+#            print STDERR "score 3:", $score, "\n";
+        }
+        if (!$p4 && $p =~ $P4_RE) {
+            $score += 1;
+            $foundhere = 1;
+            $p4 = 1;
+#            print STDERR "score 4:", $score, "\n";
+        }
+        if ($p =~ $ADV_RE) {
+            $advertising = 1;
+            $foundhere = 1;
+#            print STDERR "score (adv):", $score, "\n";
+        }
+        $foundInText .= $p;
+        last if ($score >= 9);
+    }
+    if ($score >= 5) {
+        my $license = new CHLicenses::bsd;
+        if ($advertising) {
+            $license->{version} = "advert";
+        } else {
+            $license->{version} = ""; # No version
+        }
+        $license->{foundInText} = $foundInText;
+        $license->{bsd_score} = $score;
+        return $license;
+    } else {
+        return 0;
+    }
+}
+
+sub matchLicenseText($\@) {
+    my ($self, $text) = @_;
+    return $self->matchCopyrightedFile($text);
+}
+
+sub getShortName($) {
+    "BSD";
+}
+
+sub getLongName($) {
+    my $self = shift;
+    my $version = $self->getVersion();
+    if ($version && $version eq "advert") {
+        return "BSD License with Advertising Clause";
+    } else {
+        return "BSD-like License";
+    }
+}
+




More information about the pkg-kde-commits mailing list