Fixes and formatting to configure.py
* Fix a bug in error generation regarding true/false string parsing
* Some minor style fixes
diff --git a/configure.py b/configure.py
index d31ab27..05e3e80 100644
--- a/configure.py
+++ b/configure.py
@@ -327,19 +327,20 @@
var = environ_cp.get(var_name)
if var is not None:
var_content = var.strip().lower()
- if var_content in ('1', 't', 'true', 'y', 'yes'):
+ true_strings = ('1', 't', 'true', 'y', 'yes')
+ false_strings = ('0', 'f', 'false', 'n', 'no')
+ if var_content in true_strings:
var = True
- elif var_content in ('0', 'f', 'false', 'n', 'no'):
+ elif var_content in false_strings:
var = False
else:
- raise UserInputError('Environment variable %s must be set as a boolean indicator.\n'
- 'The following are accepted as TRUE : %s.\n'
- 'The following are accepted as FALSE: %s.\n'
- 'Current value is %s' %
- (var_name,
- ','.join(true_contents),
- ','.join(false_contents),
- var))
+ raise UserInputError(
+ 'Environment variable %s must be set as a boolean indicator.\n'
+ 'The following are accepted as TRUE : %s.\n'
+ 'The following are accepted as FALSE: %s.\n'
+ 'Current value is %s.' % (
+ var_name, ', '.join(true_strings), ', '.join(false_strings),
+ var))
while var is None:
user_input_origin = get_input(question)
@@ -627,8 +628,9 @@
Raises:
UserInputError: if a query has been attempted n_ask_attempts times without
- success, assume that the user has made a scripting error, and will continue
- to provide invalid input. Raise the error to avoid infinitely looping.
+ success, assume that the user has made a scripting error, and will
+ continue to provide invalid input. Raise the error to avoid infinitely
+ looping.
"""
default = environ_cp.get(var_name) or var_default
full_query = '%s [Default is %s]: ' % (
@@ -1121,16 +1123,15 @@
computecpp_toolkit_path)
def set_trisycl_include_dir(environ_cp):
- """Set TRISYCL_INCLUDE_DIR"""
- ask_trisycl_include_dir = ('Please specify the location of the triSYCL '
- 'include directory. (Use --config=sycl_trisycl '
- 'when building with Bazel) '
- '[Default is %s]: '
- ) % (_DEFAULT_TRISYCL_INCLUDE_DIR)
+ """Set TRISYCL_INCLUDE_DIR."""
+ ask_trisycl_include_dir = (
+ 'Please specify the location of the triSYCL include directory. (Use '
+ '--config=sycl_trisycl when building with Bazel) '
+ '[Default is %s]: ') % _DEFAULT_TRISYCL_INCLUDE_DIR
while True:
trisycl_include_dir = get_from_env_or_user_or_default(
- environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
- _DEFAULT_TRISYCL_INCLUDE_DIR)
+ environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
+ _DEFAULT_TRISYCL_INCLUDE_DIR)
if os.path.exists(trisycl_include_dir):
break