All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Darander <anders@chargestorm.se>
To: openembedded-core@lists.openembedded.org
Cc: Anders Darander <anders@chargestorm.se>
Subject: [PATCH 6/7] scripts/lib/create_npm: handle AND and OR in licenses
Date: Wed,  1 Mar 2017 18:20:00 +0100	[thread overview]
Message-ID: <b984feee056fcd7df53bf2cdbfb05b91a3487611.1488388550.git.anders@chargestorm.se> (raw)
In-Reply-To: <cover.1488388550.git.anders@chargestorm.se>

Handle npm packages with multiple licenses (AND and OR).
Prior to this, AND and OR were treated as licensed in their
own.

Signed-off-by: Anders Darander <anders@chargestorm.se>
---
 scripts/lib/recipetool/create_npm.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 6a0f3c2..89973d9 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -46,6 +46,19 @@ class NpmRecipeHandler(RecipeHandler):
             if isinstance(license, dict):
                 license = license.get('type', None)
             if license:
+                if 'OR' in license:
+                    license = license.replace('OR', '|')
+                    license = license.replace('AND', '&')
+                    license = license.replace(' ', '_')
+                    if not license[0] == '(':
+                        license = '(' + license + ')'
+                    print('LICENSE: {}'.format(license))
+                else:
+                    license = license.replace('AND', '&')
+                    if license[0] == '(':
+                        license = license[1:]
+                    if license[-1] == ')':
+                        license = license[:-1]
                 license = license.replace('MIT/X11', 'MIT')
                 license = license.replace('SEE LICENSE IN EULA',
                                           'SEE-LICENSE-IN-EULA')
@@ -224,7 +237,8 @@ class NpmRecipeHandler(RecipeHandler):
                     packages = OrderedDict((x,y[0]) for x,y in npmpackages.items())
                     packages['${PN}'] = ''
                     pkglicenses = split_pkg_licenses(licvalues, packages, lines_after, licenses)
-                    all_licenses = list(set([item for pkglicense in pkglicenses.values() for item in pkglicense]))
+                    all_licenses = list(set([item.replace('_', ' ') for pkglicense in pkglicenses.values() for item in pkglicense]))
+                    all_licenses.remove('&')
                     # Go back and update the LICENSE value since we have a bit more
                     # information than when that was written out (and we know all apply
                     # vs. there being a choice, so we can join them with &)
-- 
2.10.2



  parent reply	other threads:[~2017-03-01 17:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 17:19 [PATCH 0/7] create_npm: fixes to allow eg Angular2 based applications Anders Darander
2017-03-01 17:19 ` [PATCH 1/7] create_npm.py: add devDependencies to depends Anders Darander
2017-03-02  1:44   ` Paul Eggleton
2017-03-06  7:11     ` Anders Darander
2017-03-01 17:19 ` [PATCH 2/7] create_npm.py: convert MIT/X11 to MIT Anders Darander
2017-03-03  1:18   ` Khem Raj
2017-03-06  7:21     ` Anders Darander
2017-03-09  6:22       ` Josef Holzmayr
2017-03-01 17:19 ` [PATCH 3/7] lib/oe/package.py: remove @ from package name Anders Darander
2017-03-01 17:19 ` [PATCH 4/7] classes/npm: allow installation of devDependencies Anders Darander
2017-03-01 17:19 ` [PATCH 5/7] scripts/lib/create_npm: rewrite see license in eula Anders Darander
2017-03-01 17:20 ` Anders Darander [this message]
2017-03-01 17:20 ` [PATCH 7/7] scripts/lib/create_npm: handle Public Domain licenses Anders Darander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b984feee056fcd7df53bf2cdbfb05b91a3487611.1488388550.git.anders@chargestorm.se \
    --to=anders@chargestorm.se \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.