Added similar algorithm suggestions to --lookup (#80)

This commit is contained in:
thecliguy 2020-10-28 15:56:12 +00:00 committed by GitHub
parent c2da269f06
commit a3e4f9dbaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -899,12 +899,30 @@ def algorithm_lookup(alg_names: str) -> int:
if alg_name not in algorithms_dict_flattened if alg_name not in algorithms_dict_flattened
] ]
similar_algorithms = [
alg_unknown + " --> (" + alg_type + ") " + alg_name
for alg_unknown in algorithms_not_found
for alg_type in adb.keys()
for alg_name in adb[alg_type]
# Perform a case-insensitive comparison using 'casefold'
# and match substrings using the 'in' operator.
if alg_unknown.casefold() in alg_name.casefold()
]
if len(algorithms_not_found) > 0: if len(algorithms_not_found) > 0:
retval = exitcodes.FAILURE retval = exitcodes.FAILURE
out.head('# unknown algorithms') out.head('# unknown algorithms')
for algorithm_not_found in algorithms_not_found: for algorithm_not_found in algorithms_not_found:
out.fail(algorithm_not_found) out.fail(algorithm_not_found)
print()
if len(similar_algorithms) > 0:
retval = exitcodes.FAILURE
out.head('# suggested similar algorithms')
for similar_algorithm in similar_algorithms:
out.warn(similar_algorithm)
return retval return retval