Skip to content

Commit b3a60c2

Browse files
committed
Fixed #511 - Add option to perform license validation
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 4dcf4b1 commit b3a60c2

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
==============================
22
Changelog
3+
2022-10-24
4+
Release 7.2.0
5+
6+
* Add option to validate `license_expression` in the `check` command
7+
8+
39
2022-10-24
410
Release 7.1.1
511

about.ABOUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
about_resource: .
22
name: AboutCode-toolkit
3-
version: 7.1.1
3+
version: 7.2.0
44
author: Jillian Daguil, Chin Yeung Li, Philippe Ombredanne, Thomas Druez
55
copyright: Copyright (c) nexB Inc.
66
description: |

docs/source/reference.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Options
177177

178178
.. code-block:: none
179179
180+
--license Validate the license_expression value in the input.
180181
--djc api_url api_key Validate license_expression from a DejaCode License
181182
Library API URL using the API KEY.
182183
--log FILE Path to a file to save the error messages if any.
@@ -193,6 +194,14 @@ Details
193194

194195
.. code-block:: none
195196
197+
--license
198+
Validate the license_expression value in the input.
199+
200+
If this option is not flagged, only the basic syntax is checked.
201+
No validation of the license_expression value.
202+
203+
$ about check --license /home/project/about_files/
204+
196205
---djc
197206
198207
Validate license_expression from a DejaCode License.
@@ -204,7 +213,7 @@ Details
204213
In addition, the input needs to have the 'license_expression' field.
205214
(Please contact nexB to get the api_* value for this feature)
206215
207-
$ about check --djc 'api_url' 'api_key' /home/project/about_files/
216+
$ about check --license --djc 'api_url' 'api_key' /home/project/about_files/
208217
209218
--log
210219

src/attributecode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import saneyaml
2222

23-
__version__ = '7.1.1'
23+
__version__ = '7.2.0'
2424

2525
__about_spec_version__ = '3.2.3'
2626

src/attributecode/cmd.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,10 @@ def collect_redist_src(location, output, from_inventory, with_structures, zip, q
675675
type=click.Path(
676676
exists=True, file_okay=True, dir_okay=True, readable=True, resolve_path=True))
677677

678+
@click.option('--license',
679+
is_flag=True,
680+
help='Validate the license_expression value in the input.')
681+
678682
@click.option('--djc',
679683
nargs=2,
680684
type=str,
@@ -692,7 +696,7 @@ def collect_redist_src(location, output, from_inventory, with_structures, zip, q
692696
help='Show all error and warning messages.')
693697

694698
@click.help_option('-h', '--help')
695-
def check(location, djc, log, verbose):
699+
def check(location, license, djc, log, verbose):
696700
"""
697701
Check .ABOUT file(s) at LOCATION for validity and print error messages.
698702
@@ -716,10 +720,11 @@ def check(location, djc, log, verbose):
716720
errors, abouts = collect_inventory(location)
717721

718722
# Validate license_expression
719-
from_check = True
720-
_key_text_dict, errs = pre_process_and_fetch_license_dict(abouts, from_check, api_url, api_key)
721-
for e in errs:
722-
errors.append(e)
723+
if license:
724+
from_check = True
725+
_key_text_dict, errs = pre_process_and_fetch_license_dict(abouts, from_check, api_url, api_key)
726+
for e in errs:
727+
errors.append(e)
723728

724729
severe_errors_count = report_errors(errors, quiet=False, verbose=verbose, log_file_loc=log)
725730
sys.exit(severe_errors_count)

tests/testdata/test_cmd/help/about_check_help.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Usage: about check [OPTIONS] LOCATION
55
LOCATION: Path to an ABOUT file or a directory with ABOUT files.
66

77
Options:
8+
--license Validate the license_expression value in the input.
89
--djc api_url api_key Validate license_expression from a DejaCode License
910
Library API URL using the API KEY.
1011
--log FILE Path to a file to save the error messages if any.

0 commit comments

Comments
 (0)