summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-08 19:59:31 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-08 19:59:31 +0900
commitb7ec278d2201eab4a2e894aaa0ed3a4010d18a20 (patch)
tree6445dba2dce33acb6544ebf658e3f234d9ff1e02
parent9be2dc5a70e76d49a49017a5c91e0e27594dd5a7 (diff)
downloadbuildstream-b7ec278d2201eab4a2e894aaa0ed3a4010d18a20.tar.gz
_yaml.py: Allow None for provenance argument in _yaml.assert_symbol_name()
Since we now also use this to validate user input on the command line.
-rw-r--r--buildstream/_yaml.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index 7cf743521..8954c7da9 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -1041,7 +1041,7 @@ def list_final_assertions(values):
# are required to be symbols.
#
# Args:
-# provenance (Provenance): The provenance of the loaded symbol
+# provenance (Provenance): The provenance of the loaded symbol, or None
# symbol_name (str): The loaded symbol name
# purpose (str): The purpose of the string, for an error message
# allow_dashes (bool): Whether dashes are allowed for this symbol
@@ -1072,7 +1072,9 @@ def assert_symbol_name(provenance, symbol_name, purpose, *, allow_dashes=True):
if allow_dashes:
detail += " or dashes"
+ message = "Invalid symbol name for {}: '{}'".format(purpose, symbol_name)
+ if provenance is not None:
+ message = "{}: {}".format(provenance, message)
+
raise LoadError(LoadErrorReason.INVALID_SYMBOL_NAME,
- "{}: Invalid symbol name for {}: '{}'"
- .format(provenance, purpose, symbol_name),
- detail=detail)
+ message, detail=detail)