From 41fc715cc4fa8fb3f09cf4b51e41259577a15587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 8 Sep 2021 23:09:54 +0200 Subject: [PATCH] %pyproject_save_files: Expand the namespace error message, also display it with / Related: rhbz#1950291 --- pyproject-rpm-macros.spec | 5 ++++- pyproject_save_files.py | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 07979c7..602a34d 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -12,7 +12,7 @@ License: MIT # In other cases, such as backports, increment the point # release. Version: 0 -Release: 46%{?dist} +Release: 47%{?dist} # Macro files Source001: macros.pyproject @@ -119,6 +119,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %license LICENSE %changelog +* Thu Sep 09 2021 Miro Hrončok - 0-47 +- %%pyproject_save_files: Expand the namespace error message, also display it with / + * Fri Jul 23 2021 Miro Hrončok - 0-46 - %%pyproject_buildrequires now fails when it encounters an invalid requirement - Rename %%_pyproject_ghost_distinfo and %%_pyproject_record to indicate they are private diff --git a/pyproject_save_files.py b/pyproject_save_files.py index dac8b3f..b9d656f 100644 --- a/pyproject_save_files.py +++ b/pyproject_save_files.py @@ -381,16 +381,25 @@ def parse_varargs(varargs): >>> parse_varargs(['mod', 'mod.*']) Traceback (most recent call last): ... - ValueError: Attempted to use a namespaced package with dot in the glob: mod.*. ... + ValueError: Attempted to use a namespaced package with . in the glob: mod.*. ... >>> parse_varargs(['my.bad', '+bad']) Traceback (most recent call last): ... - ValueError: Attempted to use a namespaced package with dot in the glob: my.bad. ... + ValueError: Attempted to use a namespaced package with . in the glob: my.bad. ... + + >>> parse_varargs(['mod/submod']) + Traceback (most recent call last): + ... + ValueError: Attempted to use a namespaced package with / in the glob: mod/submod. ... """ include_auto = False globs = set() - + namespace_error_template = ( + "Attempted to use a namespaced package with {symbol} in the glob: {arg}. " + "That is not (yet) supported. Use {top} instead and see " + "https://bugzilla.redhat.com/1935266 for details." + ) for arg in varargs: if arg.startswith("+"): if arg == "+auto": @@ -399,11 +408,10 @@ def parse_varargs(varargs): raise ValueError(f"Invalid argument: {arg}") elif "." in arg: top, *_ = arg.partition(".") - msg = ( - f"Attempted to use a namespaced package with dot in the glob: {arg}. " - f"That is not (yet) supported. Use {top} instead and/or file a Bugzilla explaining your use case." - ) - raise ValueError(msg) + raise ValueError(namespace_error_template.format(symbol=".", arg=arg, top=top)) + elif "/" in arg: + top, *_ = arg.partition("/") + raise ValueError(namespace_error_template.format(symbol="/", arg=arg, top=top)) else: globs.add(arg)