diff options
Diffstat (limited to 'lib/spack/spack/analyzers/__init__.py')
-rw-r--r-- | lib/spack/spack/analyzers/__init__.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/spack/spack/analyzers/__init__.py b/lib/spack/spack/analyzers/__init__.py new file mode 100644 index 0000000000..9e36ed7b3f --- /dev/null +++ b/lib/spack/spack/analyzers/__init__.py @@ -0,0 +1,43 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +"""This package contains code for creating analyzers to extract Application +Binary Interface (ABI) information, along with simple analyses that just load +existing metadata. +""" + +from __future__ import absolute_import + +import spack.util.classes +import spack.paths + +import llnl.util.tty as tty + + +mod_path = spack.paths.analyzers_path +analyzers = spack.util.classes.list_classes("spack.analyzers", mod_path) + +# The base analyzer does not have a name, and cannot do dict comprehension +analyzer_types = {} +for a in analyzers: + if not hasattr(a, "name"): + continue + analyzer_types[a.name] = a + + +def list_all(): + """A helper function to list all analyzers and their descriptions + """ + for name, analyzer in analyzer_types.items(): + print("%-25s: %-35s" % (name, analyzer.description)) + + +def get_analyzer(name): + """Courtesy function to retrieve an analyzer, and exit on error if it + does not exist. + """ + if name in analyzer_types: + return analyzer_types[name] + tty.die("Analyzer %s does not exist" % name) |