[licensecheck] 04/26: Streamline license parsing: Process loops of similar patterne.
Jonas Smedegaard
dr at jones.dk
Sun Feb 5 10:12:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository licensecheck.
commit be44d0b590fb730240fd8604a0e9df312c92949c
Author: Jonas Smedegaard <dr at jones.dk>
Date: Sat Nov 26 13:58:18 2016 +0100
Streamline license parsing: Process loops of similar patterne.
---
lib/App/Licensecheck.pm | 161 +++++++++---------------------------------------
t/Software-License.t | 2 +-
2 files changed, 29 insertions(+), 134 deletions(-)
diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index c605a5e..a67766d 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -611,28 +611,8 @@ sub parse_license
}
}
- # LLGPL
+ # NTP
given ($licensetext) {
- when ( /$L{re}{llgpl}/ ) {
- $gen_license->('llgpl');
- }
- }
-
- # QPL
- given ($licensetext) {
- when ( /$L{re}{qpl}(?: $L{re}{version}{-keep})?/ ) {
- $gen_license->( 'qpl', $1 );
- }
- }
-
- # MIT
- given ($licensetext) {
- foreach my $id (qw<curl icu isc mit_advertising mit_enna mit_feh mit_new mit_old mit_oldstyle mit_oldstyle_disclaimer mit_oldstyle_permission>) {
- when ( /$L{re}{$id}/) {
- $gen_license->($id);
- continue;
- }
- }
when ( /$L{re}{dsdp}/) {
$gen_license->('dsdp');
}
@@ -665,34 +645,6 @@ sub parse_license
$gen_license->("bsd_${1}_clause");
}
- # MPL
- given ($licensetext) {
- when ( /$L{re}{mpl},? \(?$L{re}{version}{-keep}\)?/ ) {
- $gen_license->( 'mpl', $1 );
- }
- }
-
- # APAFML
- given ($licensetext) {
- when ( /$L{re}{apafml}/ ) {
- $gen_license->('apafml');
- }
- }
-
- # Adobe-Glyph
- given ($licensetext) {
- when ( /$L{re}{'adobe_glyph'}/ ) {
- $gen_license->('adobe_glyph');
- }
- }
-
- # Adobe-2006
- given ($licensetext) {
- when ( /$L{re}{'adobe_2006'}/ ) {
- $gen_license->('adobe_2006');
- }
- }
-
# Aladdin
given ($licensetext) {
when ( /This License is not the same as any of the GNU Licenses/ ) {
@@ -742,27 +694,6 @@ sub parse_license
}
}
- # Beerware
- given ($licensetext) {
- when ( /$L{re}{beerware}/i ) {
- $gen_license->('beerware');
- }
- }
-
- # FTL
- given ($licensetext) {
- when ( /$L{re}{ftl}/i ) {
- $gen_license->('ftl');
- }
- }
-
- # FSFAP
- given ($licensetext) {
- when ( /$L{re}{fsfap}/i ) {
- $gen_license->('fsfap');
- }
- }
-
# FSFUL
given ($licensetext) {
when ( /$L{re}{fsful}/i ) {
@@ -824,20 +755,6 @@ sub parse_license
}
}
- # SGI-B
- given ($licensetext) {
- when ( /$L{re}{sgi_b}(?:\s+\(?$L{re}{version}{-keep}\)?)?/ ) {
- $gen_license->( 'sgi_b', $1 );
- }
- }
-
- # public-domain
- given ($licensetext) {
- when ( /is in $L{re}{public_domain}/i ) {
- $gen_license->('public_domain');
- }
- }
-
# CDDL
given ($licensetext) {
when ( /$L{re}{cddl}(?:,?\s+$L{re}{version}{-keep})?/ ) {
@@ -845,17 +762,10 @@ sub parse_license
}
}
- # MS-PL
- given ($licensetext) {
- when ( /$L{re}{ms_pl}/ ) {
- $gen_license->('ms_pl');
- }
- }
-
- # MS-RL
+ # public-domain
given ($licensetext) {
- when ( /$L{re}{ms_rl}/ ) {
- $gen_license->('ms_rl');
+ when ( /is in $L{re}{public_domain}/i ) {
+ $gen_license->('public_domain');
}
}
@@ -887,41 +797,6 @@ sub parse_license
}
}
- # PostgreSQL
- given ($licensetext) {
- when ( /$L{re}{postgresql}/ ) {
- $gen_license->('postgresql');
- }
- }
-
- # Python
- given ($licensetext) {
- when ( /$L{re}{python}(?:,? $L{re}{version}{-keep})?/i ) {
- $gen_license->( 'python', $1 );
- }
- }
-
- # OFL
- given ($licensetext) {
- when ( /$L{re}{ofl}(?:[ ,-]+$L{re}{version}{-keep})?/ ) {
- $gen_license->( 'ofl', $1 );
- }
- }
-
- # Unicode-strict
- given ($licensetext) {
- when ( /$L{re}{unicode_strict}/i ) {
- $gen_license->('unicode_strict');
- }
- }
-
- # Unicode-TOU
- given ($licensetext) {
- when ( /$L{re}{unicode_tou}/i ) {
- $gen_license->('unicode_tou');
- }
- }
-
# Zlib/Libpng
given ($licensetext) {
when ( /$L{re}{'zlib_acknowledgement'}/ ) {
@@ -943,14 +818,34 @@ sub parse_license
$gen_license->('libpng');
}
}
+ #>>>
- # WTFPL
given ($licensetext) {
- when ( /$L{re}{wtfpl},? $L{re}{version}{-keep}/i ) {
- $gen_license->( 'wtfpl', $1 );
+
+ # simple-versioned
+ foreach my $id (qw<mpl ofl python qpl sgi_b wtfpl>) {
+ when (/$L{re}{$id}\W*\(?$L{re}{version}{-keep}\)?/) {
+ $gen_license->( $id, $1 );
+ continue;
+ }
+ }
+
+ # unversioned
+ foreach my $id (
+ qw(
+ adobe_2006 adobe_glyph apafml
+ beerware curl fsfap ftl icu isc llgpl
+ mit_advertising mit_enna mit_feh mit_new mit_old
+ mit_oldstyle mit_oldstyle_disclaimer mit_oldstyle_permission
+ ms_pl ms_rl postgresql unicode_strict unicode_tou)
+ )
+ {
+ when (/$L{re}{$id}/) {
+ $gen_license->($id);
+ continue;
+ }
}
}
- #>>>
# Remove trailing spaces.
$license =~ s/\s+$//;
diff --git a/t/Software-License.t b/t/Software-License.t
index 33573c4..31019cb 100644
--- a/t/Software-License.t
+++ b/t/Software-License.t
@@ -18,7 +18,7 @@ my %LICENSES = (
LGPL_3_0 => 'LGPL (v3)',
MIT => 'MIT/X11 (BSD like)',
Mozilla_2_0 => 'MPL (v2.0)',
- QPL_1_0 => 'QPL',
+ QPL_1_0 => 'QPL (v1.0)',
Zlib => 'zlib/libpng',
CC0_1_0 => 'UNKNOWN',
GFDL_1_3 => 'UNKNOWN',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/licensecheck.git
More information about the Pkg-perl-cvs-commits
mailing list