3535from pprint import pformat
3636import re
3737
38+ import attr
39+ import javaproperties
40+ from license_expression import Licensing
3841from lxml import etree
3942from packageurl import PackageURL
4043from pymaven import artifact
4144from pymaven import pom
42- import attr
43- import javaproperties
4445
4546from commoncode import filetype
4647from commoncode import fileutils
47- from license_expression import Licensing
4848from packagedcode import models
4949from packagedcode .models import Package
50- from packagedcode .utils import VCS_URLS
5150from packagedcode .utils import normalize_vcs_url
51+ from packagedcode .utils import VCS_URLS
5252from textcode import analysis
5353from typecode import contenttype
5454
@@ -98,7 +98,7 @@ def get_package_root(cls, manifest_resource, codebase):
9898 if ancestor .name == 'META-INF' :
9999 jar_root_dir = ancestor .parent (codebase )
100100 return jar_root_dir
101-
101+
102102 return manifest_resource .parent (codebase )
103103
104104 elif manifest_resource .path .endswith ('META-INF/MANIFEST.MF' ):
@@ -149,10 +149,10 @@ def api_data_url(self, baseurl=default_api_baseurl):
149149 def compute_normalized_license (self ):
150150 return compute_normalized_license (self .declared_license )
151151
152+
152153def compute_normalized_license (listed_license_dictionary ):
153154 """
154- Return a detected license by parsing the passing listed license dictionary.
155- It is to combining each licenses with licensing AND feature.
155+ Return a detected license expression from a declared license mapping.
156156 """
157157 if listed_license_dictionary :
158158 licensing = Licensing ()
@@ -171,15 +171,15 @@ def compute_normalized_license(listed_license_dictionary):
171171 via_name = models .compute_normalized_license (name )
172172 via_url = models .compute_normalized_license (url )
173173 via_comments = models .compute_normalized_license (comments )
174-
174+
175175 if via_name :
176176 # The name should have precedence and any unknowns
177177 # in url and comment should be ignored.
178178 if via_url == 'unknown' :
179179 via_url = None
180180 if via_comments == 'unknown' :
181181 via_comments = None
182-
182+
183183 if via_name and ((via_name == via_url and via_comments == via_url ) or (via_name == via_url and not via_comments ) or (via_name == via_comments and not via_url )):
184184 # if three detection are the same and not empty, return the value
185185 # or one of url or comments is empty and the non-empty one equals to the name value
0 commit comments