summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/url.py43
1 files changed, 30 insertions, 13 deletions
diff --git a/lib/spack/spack/cmd/url.py b/lib/spack/spack/cmd/url.py
index f1ce050a90..a24fcc575c 100644
--- a/lib/spack/spack/cmd/url.py
+++ b/lib/spack/spack/cmd/url.py
@@ -160,10 +160,13 @@ def url_summary(args):
correct_versions = 0
# Collect statistics on which regexes were matched and how often
- name_regex_dict = dict()
- name_count_dict = defaultdict(int)
- version_regex_dict = dict()
- version_count_dict = defaultdict(int)
+ name_regex_dict = dict()
+ right_name_count = defaultdict(int)
+ wrong_name_count = defaultdict(int)
+
+ version_regex_dict = dict()
+ right_version_count = defaultdict(int)
+ wrong_version_count = defaultdict(int)
tty.msg('Generating a summary of URL parsing in Spack...')
@@ -189,9 +192,11 @@ def url_summary(args):
try:
version, vs, vl, vi, vregex = parse_version_offset(url)
version_regex_dict[vi] = vregex
- version_count_dict[vi] += 1
if version_parsed_correctly(pkg, version):
correct_versions += 1
+ right_version_count[vi] += 1
+ else:
+ wrong_version_count[vi] += 1
except UndetectableVersionError:
pass
@@ -199,9 +204,11 @@ def url_summary(args):
try:
name, ns, nl, ni, nregex = parse_name_offset(url, version)
name_regex_dict[ni] = nregex
- name_count_dict[ni] += 1
if name_parsed_correctly(pkg, name):
correct_names += 1
+ right_name_count[ni] += 1
+ else:
+ wrong_name_count[ni] += 1
except UndetectableNameError:
pass
@@ -216,24 +223,34 @@ def url_summary(args):
tty.msg('Statistics on name regular expressions:')
print()
- print(' Index Count Regular Expression')
+ print(' Index Right Wrong Total Regular Expression')
for ni in sorted(name_regex_dict.keys()):
- print(' {0:>3}: {1:>6} r{2!r}'.format(
- ni, name_count_dict[ni], name_regex_dict[ni]))
+ print(' {0:>5} {1:>5} {2:>5} {3:>5} r{4!r}'.format(
+ ni,
+ right_name_count[ni],
+ wrong_name_count[ni],
+ right_name_count[ni] + wrong_name_count[ni],
+ name_regex_dict[ni])
+ )
print()
tty.msg('Statistics on version regular expressions:')
print()
- print(' Index Count Regular Expression')
+ print(' Index Right Wrong Total Regular Expression')
for vi in sorted(version_regex_dict.keys()):
- print(' {0:>3}: {1:>6} r{2!r}'.format(
- vi, version_count_dict[vi], version_regex_dict[vi]))
+ print(' {0:>5} {1:>5} {2:>5} {3:>5} r{4!r}'.format(
+ vi,
+ right_version_count[vi],
+ wrong_version_count[vi],
+ right_version_count[vi] + wrong_version_count[vi],
+ version_regex_dict[vi])
+ )
print()
# Return statistics, only for testing purposes
return (total_urls, correct_names, correct_versions,
- name_count_dict, version_count_dict)
+ right_name_count, right_version_count)
def url_stats(args):