diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 3a4fe27..22315ff 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,27 +1,83 @@ -name: Release library as a PyPI wheel and sdist on GH release creation +name: Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch + + +# This is executed automatically on a tag in the main branch + +# Summary of the steps: +# - build wheels and sdist +# - upload wheels and sdist to PyPI +# - create gh-release and upload wheels and dists there +# TODO: smoke test wheels and sdist +# TODO: add changelog to release text body + +# WARNING: this is designed only for packages building as pure Python wheels on: - release: - types: [created] + workflow_dispatch: + push: + tags: + - "v*.*.*" jobs: - build-and-publish-to-pypi: + build-pypi-distribs: name: Build and publish library to PyPI runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@master + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Install pypa/build + run: python -m pip install build --user + + - name: Build a binary wheel and a source tarball + run: python -m build --sdist --wheel --outdir dist/ + + - name: Upload built archives + uses: actions/upload-artifact@v3 + with: + name: pypi_archives + path: dist/* + + + create-gh-release: + name: Create GH release + needs: + - build-pypi-distribs + runs-on: ubuntu-20.04 + + steps: + - name: Download built archives + uses: actions/download-artifact@v3 + with: + name: pypi_archives + path: dist + + - name: Create GH release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: dist/* + + + create-pypi-release: + name: Create PyPI release + needs: + - create-gh-release + runs-on: ubuntu-20.04 + steps: - - uses: actions/checkout@master - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - name: Install pypa/build - run: python -m pip install build --user - - name: Build a binary wheel and a source tarball - run: python -m build --sdist --wheel --outdir dist/ - . - - name: Publish distribution to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.PYPI_API_TOKEN }} - + - name: Download built archives + uses: actions/download-artifact@v3 + with: + name: pypi_archives + path: dist + + - name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e3472b2..5fe344d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,16 @@ -Release notes +Changelog ============= +v31.0.0 - 2022-08-24 +------------------------ + +- Adopt new commoncode Codebase and Resource +- Use latest skeleton +- Bump dependencies +- Drop Python 3.6 support + + v30.0.0 -------- diff --git a/MANIFEST.in b/MANIFEST.in index ef3721e..8424cbe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,7 +9,7 @@ include *.rst include setup.* include configure* include requirements* -include .git* +include .giti* global-exclude *.py[co] __pycache__ *.*~ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6ca19c4..3117a91 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,11 +7,15 @@ jobs: +################################################################################ +# These jobs are using VMs and Azure-provided Pythons 3.8 +################################################################################ + - template: etc/ci/azure-posix.yml parameters: job_name: ubuntu18_cpython image_name: ubuntu-18.04 - python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python_versions: ['3.7', '3.8', '3.9', '3.10'] test_suites: all: venv/bin/pytest -n 2 -vvs @@ -19,7 +23,15 @@ jobs: parameters: job_name: ubuntu20_cpython image_name: ubuntu-20.04 - python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python_versions: ['3.7', '3.8', '3.9', '3.10'] + test_suites: + all: venv/bin/pytest -n 2 -vvs + + - template: etc/ci/azure-posix.yml + parameters: + job_name: ubuntu22_cpython + image_name: ubuntu-22.04 + python_versions: ['3.7', '3.8', '3.9', '3.10'] test_suites: all: venv/bin/pytest -n 2 -vvs @@ -27,7 +39,7 @@ jobs: parameters: job_name: macos1015_cpython image_name: macos-10.15 - python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python_versions: ['3.7', '3.8', '3.9', '3.10'] test_suites: all: venv/bin/pytest -n 2 -vvs @@ -39,11 +51,19 @@ jobs: test_suites: all: venv/bin/pytest -n 2 -vvs + - template: etc/ci/azure-posix.yml + parameters: + job_name: macos12_cpython + image_name: macos-12 + python_versions: ['3.7', '3.8', '3.9', '3.10'] + test_suites: + all: venv/bin/pytest -n 2 -vvs + - template: etc/ci/azure-win.yml parameters: job_name: win2019_cpython image_name: windows-2019 - python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python_versions: ['3.7', '3.8', '3.9', '3.10'] test_suites: all: venv\Scripts\pytest -n 2 -vvs @@ -54,3 +74,34 @@ jobs: python_versions: ['3.7', '3.8', '3.9', '3.10'] test_suites: all: venv\Scripts\pytest -n 2 -vvs + + +################################################################################ +# Tests using a plain pip install to get the latest of all wheels +################################################################################ + + + - template: etc/ci/azure-posix.yml + parameters: + job_name: ubuntu20_cpython_latest_from_pip + image_name: ubuntu-20.04 + python_versions: ['3.7', '3.8', '3.9', '3.10'] + test_suites: + all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e . && venv/bin/pytest -n 2 -vvs + + + - template: etc/ci/azure-win.yml + parameters: + job_name: win2019_cpython_latest_from_pip + image_name: windows-2019 + python_versions: ['3.7', '3.8', '3.9', '3.10'] + test_suites: + all: venv\Scripts\pip install --upgrade-strategy eager --force-reinstall --upgrade -e . && venv\Scripts\pytest -n 2 -vvs + + - template: etc/ci/azure-posix.yml + parameters: + job_name: macos11_cpython_latest_from_pip + image_name: macos-11 + python_versions: ['3.7', '3.8', '3.9', '3.10'] + test_suites: + all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e . && venv/bin/pytest -n 2 -vvs diff --git a/configure b/configure index d1b4fda..32e02f5 100755 --- a/configure +++ b/configure @@ -52,13 +52,20 @@ CFG_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin +################################ +# Install with or without and index. With "--no-index" this is using only local wheels +# This is an offline mode with no index and no network operations +# NO_INDEX="--no-index " +NO_INDEX="" + + ################################ # Thirdparty package locations and index handling -# Find packages from the local thirdparty directory or from thirdparty.aboutcode.org -if [ -d "$CFG_ROOT_DIR/thirdparty" ]; then - PIP_EXTRA_ARGS="--find-links $CFG_ROOT_DIR/thirdparty" +# Find packages from the local thirdparty directory if present +THIRDPARDIR=$CFG_ROOT_DIR/thirdparty +if [[ "$(echo $THIRDPARDIR/*.whl)x" != "$THIRDPARDIR/*.whlx" ]]; then + PIP_EXTRA_ARGS="$NO_INDEX --find-links $THIRDPARDIR" fi -PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS --find-links https://thirdparty.aboutcode.org/pypi/simple/links.html" ################################ @@ -183,6 +190,7 @@ while getopts :-: optchar; do esac done + PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS" find_python diff --git a/configure.bat b/configure.bat index 487e78a..41547cc 100644 --- a/configure.bat +++ b/configure.bat @@ -52,11 +52,10 @@ set "CFG_BIN_DIR=%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts" @rem ################################ @rem # Thirdparty package locations and index handling -@rem # Find packages from the local thirdparty directory or from thirdparty.aboutcode.org +@rem # Find packages from the local thirdparty directory if exist "%CFG_ROOT_DIR%\thirdparty" ( set PIP_EXTRA_ARGS=--find-links "%CFG_ROOT_DIR%\thirdparty" ) -set "PIP_EXTRA_ARGS=%PIP_EXTRA_ARGS% --find-links https://thirdparty.aboutcode.org/pypi/simple/links.html" @rem ################################ @@ -69,7 +68,6 @@ if not defined CFG_QUIET ( @rem ################################ @rem # Main command line entry point set "CFG_REQUIREMENTS=%REQUIREMENTS%" -set "NO_INDEX=--no-index" :again if not "%1" == "" ( diff --git a/docs/source/conf.py b/docs/source/conf.py index 62bca04..d5435e7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -28,7 +28,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ -'sphinx.ext.intersphinx', + "sphinx.ext.intersphinx", ] # This points to aboutcode.readthedocs.io @@ -36,8 +36,8 @@ # Link was created at commit - https://github.com/nexB/aboutcode/commit/faea9fcf3248f8f198844fe34d43833224ac4a83 intersphinx_mapping = { - 'aboutcode': ('https://aboutcode.readthedocs.io/en/latest/', None), - 'scancode-workbench': ('https://scancode-workbench.readthedocs.io/en/develop/', None), + "aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None), + "scancode-workbench": ("https://scancode-workbench.readthedocs.io/en/develop/", None), } @@ -62,7 +62,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] -master_doc = 'index' +master_doc = "index" html_context = { "display_github": True, @@ -72,9 +72,7 @@ "conf_py_path": "/docs/source/", # path in the checkout to the docs root } -html_css_files = [ - '_static/theme_overrides.css' - ] +html_css_files = ["_static/theme_overrides.css"] # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. diff --git a/etc/scripts/fetch_thirdparty.py b/etc/scripts/fetch_thirdparty.py index 26d520f..89d17de 100644 --- a/etc/scripts/fetch_thirdparty.py +++ b/etc/scripts/fetch_thirdparty.py @@ -110,7 +110,6 @@ is_flag=True, help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.", ) - @click.help_option("-h", "--help") def fetch_thirdparty( requirements_files, diff --git a/etc/scripts/utils_thirdparty.py b/etc/scripts/utils_thirdparty.py index 9cbda37..53f2d33 100644 --- a/etc/scripts/utils_thirdparty.py +++ b/etc/scripts/utils_thirdparty.py @@ -311,6 +311,7 @@ def download_sdist(name, version, dest_dir=THIRDPARTY_DIR, repos=tuple()): return fetched_sdist_filename + ################################################################################ # # Core models @@ -1064,16 +1065,16 @@ def get_sdist_name_ver_ext(filename): if version.isalpha(): return False - # non-pep 440 version + # non-pep 440 version if "-" in version: return False - # single version + # single version if version.isdigit() and len(version) == 1: return False - # r1 version - if len(version) == 2 and version[0]=="r" and version[1].isdigit(): + # r1 version + if len(version) == 2 and version[0] == "r" and version[1].isdigit(): return False # dotless version (but calver is OK) @@ -1588,6 +1589,7 @@ def tags(self): ) ) + ################################################################################ # # PyPI repo and link index for package wheels and sources @@ -1629,7 +1631,9 @@ class PypiSimpleRepository: use_cached_index = attr.ib( type=bool, default=False, - metadata=dict(help="If True, use any existing on-disk cached PyPI index files. Otherwise, fetch and cache."), + metadata=dict( + help="If True, use any existing on-disk cached PyPI index files. Otherwise, fetch and cache." + ), ) def _get_package_versions_map(self, name): @@ -1674,6 +1678,7 @@ def get_package_version(self, name, version=None): """ if not version: versions = list(self._get_package_versions_map(name).values()) + # return the latest version return versions and versions[-1] else: return self._get_package_versions_map(name).get(version) @@ -1724,7 +1729,9 @@ class LinksRepository: use_cached_index = attr.ib( type=bool, default=False, - metadata=dict(help="If True, use any existing on-disk cached index files. Otherwise, fetch and cache."), + metadata=dict( + help="If True, use any existing on-disk cached index files. Otherwise, fetch and cache." + ), ) def __attrs_post_init__(self): @@ -1790,6 +1797,7 @@ def from_url(cls, url=ABOUT_BASE_URL, _LINKS_REPO={}, use_cached_index=False): _LINKS_REPO[url] = cls(url=url, use_cached_index=use_cached_index) return _LINKS_REPO[url] + ################################################################################ # Globals for remote repos to be lazily created and cached on first use for the # life of the session together with some convenience functions. @@ -1803,6 +1811,7 @@ def get_local_packages(directory=THIRDPARTY_DIR): """ return list(PypiPackage.packages_from_dir(directory=directory)) + ################################################################################ # # Basic file and URL-based operations using a persistent file-based Cache @@ -1953,6 +1962,7 @@ def fetch_and_save( fo.write(content) return content + ################################################################################ # # Functions to update or fetch ABOUT and license files @@ -2051,7 +2061,9 @@ def get_other_dists(_package, _dist): # if has key data we may look to improve later, but we can move on if local_dist.has_key_metadata(): local_dist.save_about_and_notice_files(dest_dir=dest_dir) - local_dist.fetch_license_files(dest_dir=dest_dir, use_cached_index=use_cached_index) + local_dist.fetch_license_files( + dest_dir=dest_dir, use_cached_index=use_cached_index + ) continue # lets try to fetch remotely @@ -2089,7 +2101,9 @@ def get_other_dists(_package, _dist): # if has key data we may look to improve later, but we can move on if local_dist.has_key_metadata(): local_dist.save_about_and_notice_files(dest_dir=dest_dir) - local_dist.fetch_license_files(dest_dir=dest_dir, use_cached_index=use_cached_index) + local_dist.fetch_license_files( + dest_dir=dest_dir, use_cached_index=use_cached_index + ) continue # try to get data from pkginfo (no license though) @@ -2107,6 +2121,7 @@ def get_other_dists(_package, _dist): lic_errs = "\n".join(lic_errs) print(f"Failed to fetch some licenses:: {lic_errs}") + ################################################################################ # # Functions to build new Python wheels including native on multiple OSes @@ -2210,6 +2225,7 @@ def download_wheels_with_pip( downloaded = existing ^ set(os.listdir(dest_dir)) return sorted(downloaded), error + ################################################################################ # # Functions to check for problems diff --git a/requirements-dev.txt b/requirements-dev.txt index fe92ed8..bd08a7b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,24 +1,31 @@ -aboutcode-toolkit==7.0.1 -bleach==4.1.0 +aboutcode-toolkit==7.0.2 +black==22.6.0 +bleach==5.0.1 build==0.7.0 commonmark==0.9.1 -docutils==0.18.1 +docutils==0.19 et-xmlfile==1.1.0 execnet==1.9.0 iniconfig==1.1.1 -jeepney==0.7.1 -keyring==23.4.1 -openpyxl==3.0.9 +isort==5.10.1 +jeepney==0.8.0 +keyring==23.7.0 +mypy-extensions==0.4.3 +openpyxl==3.0.10 +pathspec==0.9.0 pep517==0.12.0 -pkginfo==1.8.2 +pkginfo==1.8.3 +platformdirs==2.5.2 py==1.11.0 -pytest==7.0.1 +pytest==7.1.2 pytest-forked==1.4.0 pytest-xdist==2.5.0 -readme-renderer==34.0 +readme-renderer==35.0 requests-toolbelt==0.9.1 -rfc3986==1.5.0 -rich==12.3.0 +rfc3986==2.0.0 +rich==12.5.1 secretstorage==3.3.2 -tomli==1.2.3 -twine==3.8.0 +tomli==2.0.1 +tqdm==4.64.0 +twine==4.0.1 +typing_extensions==4.3.0 diff --git a/requirements.txt b/requirements.txt index 50f80ee..3ca8ceb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,50 +2,47 @@ attrs==21.4.0 banal==1.0.6 beautifulsoup4==4.11.1 binaryornot==0.4.4 -boolean.py==3.8 -certifi==2021.10.8 -cffi==1.15.0 -chardet==4.0.0 -charset-normalizer==2.0.12 -click==8.0.4 -colorama==0.4.4 -commoncode==30.2.0 +boolean.py==4.0 +certifi==2022.6.15 +cffi==1.15.1 +chardet==5.0.0 +charset-normalizer==2.1.0 +click==8.1.3 +colorama==0.4.5 +commoncode==31.0.0 construct==2.10.68 -container-inspector==30.0.0 -cryptography==36.0.2 -debian-inspector==30.0.0 +container-inspector==31.1.0 +cryptography==37.0.4 dockerfile-parse==1.2.0 dparse2==0.6.1 -extractcode==30.0.0 +extractcode==31.0.0 extractcode-7z==16.5.210531 extractcode-libarchive==3.5.1.210531 fasteners==0.17.3 fingerprints==1.0.3 -ftfy==6.0.3 +ftfy==6.1.1 future==0.18.2 gemfileparser==0.8.0 html5lib==1.1 idna==3.3 -importlib-metadata==4.8.3 +importlib-metadata==4.12.0 inflection==0.5.1 intbitset==3.0.1 isodate==0.6.1 -jaraco.functools==3.4.0 +jaraco.functools==3.5.1 javaproperties==0.8.1 -Jinja2==3.0.3 +Jinja2==3.1.2 jsonstreams==0.6.0 -license-expression==21.6.14 -lxml==4.8.0 -MarkupSafe==2.0.1 +license-expression==30.0.0 +lxml==4.9.1 +MarkupSafe==2.1.1 more-itertools==8.13.0 normality==2.3.3 -packagedcode-msitools==0.101.210706 -packageurl-python==0.9.9 +packageurl-python==0.10.0 packaging==21.3 parameter-expansion-patched==0.3.1 -patch==1.16 -pdfminer.six==20220506 -pefile==2021.9.3 +pdfminer.six==20220524 +pefile==2022.5.30 pip-requirements-parser==31.2.0 pkginfo2==30.0.0 pluggy==1.0.0 @@ -56,24 +53,23 @@ pycparser==2.21 pygmars==0.7.0 Pygments==2.12.0 pymaven-patch==0.3.0 -pyparsing==3.0.8 +pyparsing==3.0.9 pytz==2022.1 PyYAML==6.0 -rdflib==5.0.0 -regipy==2.2.2 -requests==2.27.1 -rpm-inspector-rpm==4.16.1.3.210404 +rdflib==6.2.0 +requests==2.28.1 saneyaml==0.5.2 six==1.16.0 -soupsieve==2.3.1 +soupsieve==2.3.2.post1 spdx-tools==0.7.0a3 text-unidecode==1.3 toml==0.10.2 -typecode==21.6.1 +typecode==30.0.0 typecode-libmagic==5.39.210531 -urllib3==1.26.9 +typing-extensions==4.3.0 +urllib3==1.26.11 urlpy==0.5 wcwidth==0.2.5 webencodings==0.5.1 -xmltodict==0.12.0 -zipp==3.6.0 +xmltodict==0.13.0 +zipp==3.8.1 diff --git a/setup.cfg b/setup.cfg index e13d962..53df7e3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,11 +16,6 @@ classifiers = Intended Audience :: Developers Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 Topic :: Software Development Topic :: Utilities @@ -31,12 +26,15 @@ keywords = scancode scancode-toolkit plugins + open source + plugin license_files = apache-2.0.LICENSE NOTICE AUTHORS.rst CHANGELOG.rst + CODE_OF_CONDUCT.rst [options] package_dir = @@ -47,11 +45,11 @@ zip_safe = false setup_requires = setuptools_scm[toml] >= 4 -python_requires = >=3.6.* +python_requires = >=3.7 install_requires = click >= 6.7, !=7.0 - commoncode >= 30.2.0 + commoncode >= 31.0.0 pluggy >= 0.12.0 diff --git a/src/plugincode/__init__.py b/src/plugincode/__init__.py index 388a3b5..a6c5fc3 100644 --- a/src/plugincode/__init__.py +++ b/src/plugincode/__init__.py @@ -1,22 +1,11 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. # -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# + from collections import defaultdict import sys diff --git a/src/plugincode/location_provider.py b/src/plugincode/location_provider.py index ec4f992..d2d0be8 100644 --- a/src/plugincode/location_provider.py +++ b/src/plugincode/location_provider.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. import logging import os diff --git a/src/plugincode/output.py b/src/plugincode/output.py index 7373a80..e17c026 100644 --- a/src/plugincode/output.py +++ b/src/plugincode/output.py @@ -1,22 +1,10 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. + import functools from commoncode.resource import Resource @@ -77,11 +65,24 @@ def get_files(cls, codebase, **kwargs): """ # FIXME: serialization SHOULD NOT be needed: only some format need it # (e.g. JSON) and only these should serialize - timing = kwargs.get("timing", False) - info = bool(kwargs.get("info") or getattr(codebase, "with_info", False)) - serializer = functools.partial(Resource.to_dict, with_info=info, with_timing=timing) + with_timing = kwargs.get("timing", False) + with_info = bool(kwargs.get("info") or getattr(codebase, "with_info", False)) + + full_root = kwargs.get("full_root", False) + + if codebase.has_single_resource: + strip_root = False + else: + strip_root = kwargs.get("strip_root", False) + + serializer = functools.partial( + Resource.to_dict, + with_info=with_info, + with_timing=with_timing, + full_root=full_root, + strip_root=strip_root, + ) - strip_root = kwargs.get("strip_root", False) resources = codebase.walk_filtered(topdown=True, skip_root=strip_root) return map(serializer, resources) diff --git a/src/plugincode/output_filter.py b/src/plugincode/output_filter.py index 5a99fb5..2a873b4 100644 --- a/src/plugincode/output_filter.py +++ b/src/plugincode/output_filter.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. from plugincode import CodebasePlugin from plugincode import PluginManager diff --git a/src/plugincode/post_scan.py b/src/plugincode/post_scan.py index 4ba5f69..1ab259e 100644 --- a/src/plugincode/post_scan.py +++ b/src/plugincode/post_scan.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. from plugincode import CodebasePlugin from plugincode import PluginManager diff --git a/src/plugincode/pre_scan.py b/src/plugincode/pre_scan.py index 9d7c19f..2ea6c5b 100644 --- a/src/plugincode/pre_scan.py +++ b/src/plugincode/pre_scan.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. from plugincode import CodebasePlugin from plugincode import PluginManager diff --git a/src/plugincode/scan.py b/src/plugincode/scan.py index 9aa78b4..9c473be 100644 --- a/src/plugincode/scan.py +++ b/src/plugincode/scan.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. from plugincode import CodebasePlugin from plugincode import PluginManager diff --git a/tests/plugincode/test_plugincode.py b/tests/plugincode/test_plugincode.py index fcf7742..f65daa9 100644 --- a/tests/plugincode/test_plugincode.py +++ b/tests/plugincode/test_plugincode.py @@ -1,22 +1,9 @@ # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# -# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. -# ScanCode is a trademark of nexB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/plugincode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. def test_plugincode_can_be_imported():