diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2023-10-31 15:08:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-31 15:08:41 +0100 |
commit | 40a5c1ff2d54a4fc547205cb1068bcf5c21981e3 (patch) | |
tree | 88c7302c26517d81ed9fa01151f500d10313f105 /lib | |
parent | 6933e1c3cbba4bfb92296459fc8d5d125ef262e7 (diff) | |
download | spack-40a5c1ff2d54a4fc547205cb1068bcf5c21981e3.tar.gz spack-40a5c1ff2d54a4fc547205cb1068bcf5c21981e3.tar.bz2 spack-40a5c1ff2d54a4fc547205cb1068bcf5c21981e3.tar.xz spack-40a5c1ff2d54a4fc547205cb1068bcf5c21981e3.zip |
spack checksum: fix error when initial filter yields empty list (#40799)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/stage.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py index 03689c39ba..7418b5a44e 100644 --- a/lib/spack/spack/stage.py +++ b/lib/spack/spack/stage.py @@ -893,9 +893,9 @@ def interactive_version_filter( """ # Find length of longest string in the list for padding version_filter = initial_verion_filter or VersionList([":"]) + max_len = max(len(str(v)) for v in url_dict) if url_dict else 0 sorted_and_filtered = [v for v in url_dict if v.satisfies(version_filter)] sorted_and_filtered.sort(reverse=True) - max_len = max(len(str(v)) for v in sorted_and_filtered) orig_url_dict = url_dict # only copy when using editor to modify print_header = True VERSION_COLOR = spack.spec.VERSION_COLOR @@ -903,21 +903,20 @@ def interactive_version_filter( if print_header: has_filter = version_filter != VersionList([":"]) header = [] - if not sorted_and_filtered: - header.append("No versions selected") - elif len(sorted_and_filtered) == len(orig_url_dict): + if len(orig_url_dict) > 0 and len(sorted_and_filtered) == len(orig_url_dict): header.append( f"Selected {llnl.string.plural(len(sorted_and_filtered), 'version')}" ) else: header.append( - f"Selected {len(sorted_and_filtered)} of {len(orig_url_dict)} versions" + f"Selected {len(sorted_and_filtered)} of " + f"{llnl.string.plural(len(orig_url_dict), 'version')}" ) if sorted_and_filtered and known_versions: num_new = sum(1 for v in sorted_and_filtered if v not in known_versions) header.append(f"{llnl.string.plural(num_new, 'new version')}") if has_filter: - header.append(colorize(f"Filtered by {VERSION_COLOR}{version_filter}@.")) + header.append(colorize(f"Filtered by {VERSION_COLOR}@@{version_filter}@.")) version_with_url = [ colorize( |