Skip to content

Commit

Permalink
Allow copyright ownwer and copyright title to be a regexp. Make C4 ru…
Browse files Browse the repository at this point in the history
…les use optional 'The' in copyright title.
  • Loading branch information
netsettler committed Aug 2, 2023
1 parent b177118 commit 87e46c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions dcicutils/license_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def report(message):
parsed = cls.parse_simple_license_file(filename=filename)
if check_license_title:
license_title = parsed['license-title']
if license_title != check_license_title:
report(f"The license, {license_title!r}, was expected to be {check_license_title!r}.")
if not re.match(check_license_title, license_title):
report(f"The license, {license_title!r}, was expected to match {check_license_title!r}.")
if check_copyright_year:
if check_copyright_year is True:
check_copyright_year = str(datetime.datetime.now().year)
Expand All @@ -285,8 +285,8 @@ def report(message):
report(f"The copyright year, {copyright_year!r}, should have {check_copyright_year!r} at the end.")
if check_copyright_owner:
copyright_owner = parsed['copyright-owner']
if copyright_owner != check_copyright_owner:
report(f"The copyright owner, {copyright_owner!r}, was expected to be {check_copyright_owner!r}.")
if not re.match(check_copyright_owner, copyright_owner):
report(f"The copyright owner, {copyright_owner!r}, was expected to match {check_copyright_owner!r}.")


class LicenseChecker:
Expand Down Expand Up @@ -531,7 +531,7 @@ class C4InfrastructureLicenseChecker(LicenseChecker):
"""

COPYRIGHT_OWNER = "President and Fellows of Harvard College"
LICENSE_TITLE = "The MIT License"
LICENSE_TITLE = "(The )?MIT License"
LICENSE_FRAMEWORKS = ['python', 'javascript']

ALLOWED = [
Expand Down Expand Up @@ -729,7 +729,7 @@ class C4InfrastructureLicenseChecker(LicenseChecker):

# This seems to be a BSD-3-Clause-Modification license.
# Ref: https://github.com/Pylons/translationstring/blob/master/LICENSE.txt
# 'translationstring',
'translationstring',

# This seems to be a BSD-3-Clause-Modification license.
# Ref: https://github.com/Pylons/venusian/blob/master/LICENSE.txt
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "7.6.0.2b9"
version = "7.6.0.2b10"
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down
5 changes: 3 additions & 2 deletions test/test_license_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def perturb_setup():

def checker(printed, license_warnings):
ignored(printed) # tested elsewhere
assert "The license, 'BAD TITLE', was expected to be 'Some License'." in license_warnings
assert "The license, 'BAD TITLE', was expected to match 'Some License'." in license_warnings

check_license_checker_full_scenario_failing_generic(
perturb_setup=perturb_setup,
Expand Down Expand Up @@ -491,7 +491,8 @@ def test_license_checker_bad_license_owner():

def checker(printed, license_warnings):
ignored(printed) # tested elsewhere
assert (f"The copyright owner, 'Someone different', was expected to be {DEFAULT_COPYRIGHT_OWNER_FOR_TESTING!r}."
assert ((f"The copyright owner, 'Someone different',"
f" was expected to match {DEFAULT_COPYRIGHT_OWNER_FOR_TESTING!r}.")
in license_warnings)

check_license_checker_full_scenario_failing_generic(
Expand Down

0 comments on commit 87e46c3

Please sign in to comment.