From 791b930930b9ddcb752c97c8a8ef859b7afbeb0e Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 30 May 2018 20:19:08 +0200 Subject: 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. --- kconfiglib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'kconfiglib.py') 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 # -- cgit v1.2.3