From 255e807af4011d90e87056e176300dd008b6d764 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 27 Sep 2023 14:59:34 +0530 Subject: [PATCH] Add new attributes for curations Adds two new attributes: - deployed_resource - is_curated These are used to curate resources in deployed code. Reference: https://github.com/nexB/scancode.io/issues/834 Signed-off-by: Ayan Sinha Mahapatra --- CHANGELOG.rst | 7 ++++++ README.rst | 2 +- docs/source/general.rst | 6 +++++ docs/source/home.rst | 2 +- docs/source/specification.rst | 15 ++++++++++++- src/attributecode/__init__.py | 4 ++-- src/attributecode/model.py | 22 +++++-------------- tests/test_model.py | 11 ++++++++++ .../parse/with_deployed_resource.ABOUT | 4 ++++ 9 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 tests/testdata/test_model/parse/with_deployed_resource.ABOUT diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 185b14df..92c41460 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ ============================== Changelog +2023-09-28 + Release 11.0.0 + + * Adopt 3.3.2 specification: introducinf the following fields: + - ``deployed_resource`` + - ``is_curated`` + 2023-09-25 Release 10.1.0 diff --git a/README.rst b/README.rst index f97cc8e7..c4033dee 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ In addition, this tool is able to generate attribution notices and identify redistributable source code used in your project to help you comply with open source licenses conditions. -This version of the AboutCode Toolkit follows the ABOUT specification version 3.3.1 at: +This version of the AboutCode Toolkit follows the ABOUT specification version 3.3.2 at: https://aboutcode-toolkit.readthedocs.io/en/latest/specification.html diff --git a/docs/source/general.rst b/docs/source/general.rst index 1676a030..607fa4a2 100644 --- a/docs/source/general.rst +++ b/docs/source/general.rst @@ -88,6 +88,9 @@ it will copy and store next to the .ABOUT files. * - ignored_resources - List of paths ignored from the ``about_resource`` - Optional + * - deployed_resource + - Path to the resource where the curated resource is deployed + - Optional * - version - Component version - Optional @@ -148,6 +151,9 @@ it will copy and store next to the .ABOUT files. * - internal_use_only - Yes/No. Is the component internal use only. - Optional + * - is_curation + - Yes/No. Is the ABOUT file for a curated resource + - Optional * - changelog_file - changelog text file name - Optional diff --git a/docs/source/home.rst b/docs/source/home.rst index f57108b5..753c8c48 100644 --- a/docs/source/home.rst +++ b/docs/source/home.rst @@ -20,7 +20,7 @@ In addition, this tool is able to generate attribution notices and identify redistributable source code used in your project to help you comply with open source licenses conditions. -This version of the AboutCode Toolkit follows the ABOUT specification version 3.3.1 at: +This version of the AboutCode Toolkit follows the ABOUT specification version 3.3.2 at: https://aboutcode-toolkit.readthedocs.io/en/latest/specification.html diff --git a/docs/source/specification.rst b/docs/source/specification.rst index dd05990f..0f21cf7f 100644 --- a/docs/source/specification.rst +++ b/docs/source/specification.rst @@ -1,7 +1,7 @@ .. _specification: =============================== -ABOUT File Specification v3.3.1 +ABOUT File Specification v3.3.2 =============================== Purpose @@ -251,6 +251,15 @@ sub-paths under the directory ignored: about_resource: linux-kernel-2.6.23 ignored_resources: linux-kernel-2.6.23/Documentation +In this example the ABOUT file is being used to curate resources on the deployed +side of the code: + + .. code-block:: none + + about_resource: elasticsearch + deployed_resource: elasticsearch-2.3.4.jar + is_curated: yes + In this example, the ABOUT file documents the current directory, using a "." period to reference it: .. code-block:: none @@ -272,6 +281,8 @@ Optional Information fields - ignored_resources: A list of paths under the ``about_resource`` path, which are not documented in the ABOUT file, and the information in the ABOUT file does not apply to these subpaths. +- deployed_resource: A single path or a list of paths which point to the resource + where the documented resouce is deployed. - version: Component or package version. A component or package usually has a version, such as a revision number or hash from a version control system (for a snapshot checked out from VCS such as Subversion or Git). If not available, the version should be the date @@ -359,6 +370,8 @@ Optional Boolean flag fields - modified: Set this flag to yes if the component has been modified. Defaults to no when absent. - internal_use_only: Set this flag to yes if the component is used internal only. Defaults to no when absent. +- is_curated: Set this flag to yes if the ABOUT file is being used to curate a resource on the + deployed code, instead of just plain documenting resources. Optional Extension fields ------------------------- diff --git a/src/attributecode/__init__.py b/src/attributecode/__init__.py index fb3477e0..6fc97a45 100644 --- a/src/attributecode/__init__.py +++ b/src/attributecode/__init__.py @@ -20,9 +20,9 @@ import saneyaml -__version__ = '10.1.0' +__version__ = '11.0.0' -__about_spec_version__ = '3.3.1' +__about_spec_version__ = '3.3.2' __copyright__ = """ Copyright (c) nexB Inc. All rights reserved. http://dejacode.org diff --git a/src/attributecode/model.py b/src/attributecode/model.py index 0ea0ae6d..a358496d 100644 --- a/src/attributecode/model.py +++ b/src/attributecode/model.py @@ -551,7 +551,8 @@ def _validate(self, *args, **kwargs): class AboutResourceField(PathField): """ - Special field for about_resource. self.resolved_paths contains a list of + Special field for about_resource, which points to the path(s) that the ABOUT + file is documenting. self.resolved_paths contains a list of the paths resolved relative to the about file path. """ @@ -564,22 +565,6 @@ def _validate(self, *args, **kwargs): return errors -class IgnoredResourcesField(PathField): - """ - Special field for ignored_resources. self.ignored_paths contains a list of - path patterns (glob patterns) which are not part of the summarization provided - by the ABOUT file. - """ - - def __init__(self, *args, ** kwargs): - super(AboutResourceField, self).__init__(*args, ** kwargs) - self.resolved_paths = [] - - def _validate(self, *args, **kwargs): - errors = super(AboutResourceField, self)._validate(*args, ** kwargs) - return errors - - class FileTextField(PathField): """ A path field pointing to one or more text files such as license files. @@ -789,6 +774,7 @@ def set_standard_fields(self): self.fields = dict([ ('about_resource', AboutResourceField(required=True)), ('ignored_resources', AboutResourceField()), + ('deployed_resource', AboutResourceField()), ('name', SingleLineField(required=True)), ('version', SingleLineField()), @@ -815,6 +801,8 @@ def set_standard_fields(self): ('modified', BooleanField()), ('internal_use_only', BooleanField()), + ('is_curation', BooleanField()), + ('changelog_file', FileTextField()), ('owner', StringField()), diff --git a/tests/test_model.py b/tests/test_model.py index 251fb5c0..15514c49 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -478,6 +478,17 @@ def test_About_loads_ignored_resources_field(self): result = [f.name for f in a.all_fields() if f.present] assert expected == result + def test_About_loads_deployed_resource_field(self): + # fields in this file are not in the standard order + test_file = get_test_loc( + 'test_model/parse/with_deployed_resource.ABOUT') + a = model.About(test_file) + # assert [] == a.errors + + expected = ['about_resource', 'deployed_resource', 'name', 'is_curated'] + result = [f.name for f in a.all_fields() if f.present] + assert expected == result + def test_About_has_errors_when_about_resource_is_missing(self): test_file = get_test_loc('test_gen/parser_tests/.ABOUT') a = model.About(test_file) diff --git a/tests/testdata/test_model/parse/with_deployed_resource.ABOUT b/tests/testdata/test_model/parse/with_deployed_resource.ABOUT new file mode 100644 index 00000000..16afadd7 --- /dev/null +++ b/tests/testdata/test_model/parse/with_deployed_resource.ABOUT @@ -0,0 +1,4 @@ +name: elasticsearch-sidecar +about_resource: elasticsearch-sidecar +deployed_resource: elasticsearch-sidecar.jar +is_curated: yes \ No newline at end of file