diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-30 20:19:08 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-30 20:38:11 +0200 |
| commit | 791b930930b9ddcb752c97c8a8ef859b7afbeb0e (patch) | |
| tree | 269fac721dc55365f6582e521d511c87a19f03b0 /kconfiglib.py | |
| parent | 38cca3bdeca7d91044e11ddf2193e07c5d223ad3 (diff) | |
Add tool helper for selecting the top-level Kconfig
standard_kconfig() gets the top-level Kconfig file from the first
command-line argument, defaulting to "Kconfig". This removes some
boilerplate from tools.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index d69da5b..1b57821 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4485,6 +4485,16 @@ def unescape(s): """ return _unescape_re_sub(r"\1", s) +def standard_kconfig(): + """ + Helper for implementing tools. Loads either a top-level Kconfig specified + as an argument, or "Kconfig" otherwise. Returns the Kconfig instance. + """ + if len(sys.argv) > 2: + sys.exit("usage: {} [Kconfig]".format(sys.argv[0])) + + return Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1]) + # # Internal functions # |
