scripts: Simplify code with sys.exit(<string>)
Promote a handy and often-overlooked sys.exit() feature: Passing it a
string (or any other non-int object) prints it to stderr and exits with
status 1.
See the documentation at
https://docs.python.org/3/library/sys.html#sys.exit.
This indirectly prints some errors to stderr that previously went to
stdout.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
diff --git a/scripts/sanity_chk/expr_parser.py b/scripts/sanity_chk/expr_parser.py
index 3d3ad28..b28af21 100644
--- a/scripts/sanity_chk/expr_parser.py
+++ b/scripts/sanity_chk/expr_parser.py
@@ -14,10 +14,9 @@
import ply.lex as lex
import ply.yacc as yacc
except ImportError:
- print("PLY library for Python 3 not installed.")
- print("Please install the ply package using your workstation's")
- print("package manager or the 'pip' tool.")
- sys.exit(1)
+ sys.exit("PLY library for Python 3 not installed.\n"
+ "Please install the ply package using your workstation's\n"
+ "package manager or the 'pip' tool.")
reserved = {
'and' : 'AND',