From e1ccf19f9f5fc896dfeef15883d2cb455cbbb937 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 29 Oct 2019 16:41:03 +0100 Subject: Add public helpers for generating " (defined at ...)" strings Have Symbol/Choice.name_and_loc return strings like "MY_SYM (defined at foo:1, bar:2)" " (defined at foo:4)" I've added a function like that in at least four different scripts now, so that's probably a sign that it's a worthwhile helper. Clean up the tests/Klocation tests a bit while adding tests. --- examples/merge_config.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/merge_config.py b/examples/merge_config.py index ef11d79..528e86c 100755 --- a/examples/merge_config.py +++ b/examples/merge_config.py @@ -104,18 +104,6 @@ print(kconf.write_config(sys.argv[2])) # Print warnings for symbols whose actual value doesn't match the assigned # value - -def name_and_loc(sym): - # Helper for printing symbol names and Kconfig file location(s) in warnings - - if not sym.nodes: - return sym.name + " (undefined)" - - return "{} (defined at {})".format( - sym.name, - ", ".join("{}:{}".format(node.filename, node.linenr) - for node in sym.nodes)) - for sym in kconf.defined_syms: # Was the symbol assigned to? if sym.user_value is not None: @@ -129,5 +117,5 @@ for sym in kconf.defined_syms: if user_value != sym.str_value: print("warning: {} was assigned the value '{}' but got the " "value '{}' -- check dependencies".format( - name_and_loc(sym), user_value, sym.str_value), + sym.name_and_loc, user_value, sym.str_value), file=sys.stderr) -- cgit v1.2.3