Skip to content

Commit 86c7db5

Browse files
authored
Merge pull request #2875 from nexB/2861-license-clarity-update
Improve license clarity scoring
2 parents e080f83 + f998e21 commit 86c7db5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2929
-3562
lines changed

CHANGELOG.rst

Lines changed: 131 additions & 71 deletions
Large diffs are not rendered by default.

src/summarycode/classify.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def process_codebase(self, codebase, classify, **kwargs):
172172
has_package_data = hasattr(codebase.root, 'package_data')
173173
if not has_package_data:
174174
# FIXME: this is not correct... we may still have cases where this
175-
# is wrong: e.g. a META-INF directory and we may not have a package
175+
# is wrong: e.g. a META-INF directory and we may not have a package
176176
return
177177

178178

@@ -286,7 +286,7 @@ def process_codebase(self, codebase, classify, **kwargs):
286286
'/setup.cfg': 'pypi',
287287
'/setup.py': 'pypi',
288288
'/PKG-INFO': 'pypi',
289-
'/pyproject.toml': 'pypi',
289+
'/pyproject.toml': 'pypi',
290290
'.spec': 'rpm',
291291
'/cargo.toml': 'rust',
292292
'.spdx': 'spdx',
@@ -310,18 +310,32 @@ def process_codebase(self, codebase, classify, **kwargs):
310310
)
311311

312312

313+
def check_resource_name_start_and_end(resource, STARTS_ENDS):
314+
"""
315+
Return True if `resource.name` or `resource.base_name` begins or ends with
316+
an element of `STARTS_ENDS`
317+
"""
318+
name = resource.name.lower()
319+
base_name = resource.base_name.lower()
320+
return (
321+
name.startswith(STARTS_ENDS)
322+
or name.endswith(STARTS_ENDS)
323+
or base_name.startswith(STARTS_ENDS)
324+
or base_name.endswith(STARTS_ENDS)
325+
)
326+
327+
313328
def set_classification_flags(resource,
314329
_LEGAL=LEGAL_STARTS_ENDS,
315330
_MANIF=MANIFEST_ENDS,
316331
_README=README_STARTS_ENDS):
317332
"""
318333
Set classification flags on the `resource` Resource
319334
"""
320-
name = resource.name.lower()
321335
path = resource.path.lower()
322336

323-
resource.is_legal = is_legal = name.startswith(_LEGAL) or name.endswith(_LEGAL)
324-
resource.is_readme = is_readme = name.startswith(_README) or name.endswith(_README)
337+
resource.is_legal = is_legal = check_resource_name_start_and_end(resource, _LEGAL)
338+
resource.is_readme = is_readme = check_resource_name_start_and_end(resource, _README)
325339
resource.is_manifest = is_manifest = path.endswith(_MANIF)
326340
resource.is_key_file = (resource.is_top_level
327341
and (is_readme or is_legal or is_manifest))

0 commit comments

Comments
 (0)