Skip to content

Commit

Permalink
Normalize holders from package data #2972
Browse files Browse the repository at this point in the history
    * Update expected test results

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed May 24, 2022
1 parent 269754c commit a0011b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/summarycode/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ def get_primary_language(programming_language_tallies):

def get_origin_info_from_top_level_packages(top_level_packages, codebase):
"""
Return a 3-tuple containing the strings of declared license expression,
copyright holder, and primary programming language from a
Return a 3-tuple containing the declared license expression string, a list
of copyright holder, and primary programming language string from a
``top_level_packages`` list of detected top-level packages mapping and a
``codebase``.
"""
if not top_level_packages:
return '', '', ''
return '', [], ''

license_expressions = []
programming_languages = []
Expand Down Expand Up @@ -272,6 +272,9 @@ def get_origin_info_from_top_level_packages(top_level_packages, codebase):
continue
holders = [h['holder'] for h in key_file_resource.holders]
declared_holders.extend(holders)
# Normalize holder names before collecting them
# This allows us to properly remove declared holders from `other_holders` later
declared_holders = [canonical_holder(h) for h in declared_holders]
declared_holders = unique(declared_holders)

# Programming language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"conflicting_license_categories": false,
"ambiguous_compound_licensing": false
},
"declared_holder": "Mort Bay Consulting Pty. Ltd. (Australia) and others, Sun Microsystems, Inc.",
"declared_holder": "Mort Bay Consulting Pty. Ltd. (Australia) and others, Sun Microsystems",
"primary_language": "",
"other_license_expressions": [],
"other_holders": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@
"conflicting_license_categories": false,
"ambiguous_compound_licensing": false
},
"declared_holder": "Example Corporation, Google Inc., Fraunhofer FKIE",
"declared_holder": "Google, Fraunhofer FKIE",
"primary_language": "Python",
"other_license_expressions": [],
"other_holders": [],
"other_holders": [
{
"value": "Example Corporation",
"count": 1
}
],
"other_languages": []
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"count": 1
},
{
"value": "Sun Microsystems, Inc.",
"value": "Sun Microsystems",
"count": 1
}
],
Expand Down

0 comments on commit a0011b1

Please sign in to comment.