Change several python and robot files to 110 chars
Taking advantage of current team limit of 110 chars.
Change-Id: If7ab51fe894889967b8c8bb2f2fa4664f01117d5
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/valid.tcl b/lib/valid.tcl
index 4d5bdb0..aea4b3d 100755
--- a/lib/valid.tcl
+++ b/lib/valid.tcl
@@ -1,39 +1,29 @@
#!/usr/bin/wish
-# This file provides many valuable validation procedures such as valid_value,
-# valid_integer, etc.
+# This file provides many valuable validation procedures such as valid_value, valid_integer, etc.
my_source [list print.tcl call_stack.tcl]
proc valid_value { var_name { invalid_values {}} { valid_values {}} } {
- # If the value of the variable named in var_name is not valid, print an
- # error message and exit the program with a non-zero return code.
+ # If the value of the variable named in var_name is not valid, print an error message and exit the program
+ # with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated.
- # invalid_values A list of invalid values. If the variable
- # value is equal to any value in the
- # invalid_values list, it is deemed to be
- # invalid. Note that if you specify
- # anything for invalid_values (below), the
- # valid_values list is not even processed.
- # In other words, specify either
- # invalid_values or valid_values but not
- # both. If no value is specified for either
- # invalid_values or valid_values,
- # invalid_values will default to a list with
- # one blank entry. This is useful if you
- # simply want to ensure that your variable
- # is non blank.
- # valid_values A list of invalid values. The variable
- # value must be equal to one of the values
- # in this list to be considered valid.
+ # var_name The name of the variable whose value is to be validated.
+ # invalid_values A list of invalid values. If the variable value is equal to any value in
+ # the invalid_values list, it is deemed to be invalid. Note that if you
+ # specify anything for invalid_values (below), the valid_values list is not
+ # even processed. In other words, specify either invalid_values or
+ # valid_values but not both. If no value is specified for either
+ # invalid_values or valid_values, invalid_values will default to a list
+ # with one blank entry. This is useful if you simply want to ensure that
+ # your variable is non blank.
+ # valid_values A list of invalid values. The variable value must be equal to one of the
+ # values in this list to be considered valid.
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -97,16 +87,14 @@
proc valid_list { var_name args } {
- # If the value of the list variable named in var_name is not valid, print
- # an error message and exit the program with a non-zero return code.
+ # If the value of the list variable named in var_name is not valid, print an error message and exit the
+ # program with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated. This variable should be a
- # list. For each list alement, a call to
- # valid_value will be done.
- # args args will be passed directly to
- # valid_value. Please see valid_value for
+ # var_name The name of the variable whose value is to be validated. This variable
+ # should be a list. For each list alement, a call to valid_value will be
+ # done.
+ # args args will be passed directly to valid_value. Please see valid_value for
# details.
# Example call:
@@ -117,8 +105,8 @@
# In this example, this procedure will fail with the following message:
- ##(CDT) 2018/03/27 12:26:49.904870 - **ERROR** The following list has one
- # #or more invalid values (marked with "*"):
+ ##(CDT) 2018/03/27 12:26:49.904870 - **ERROR** The following list has one or more invalid values (marked
+ # #with "*"):
#
# proc_names:
# proc_names[0]: zero*
@@ -134,8 +122,7 @@
# valid_values[1]: two
# valid_values[2]: three
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -153,20 +140,17 @@
# No errors found so return.
if { [llength $invalid_ix_list] == 0 } { return }
- # We want to do a print_list on the caller's list but we want to put an
- # asterisk by each invalid entry (see example in prolog).
+ # We want to do a print_list on the caller's list but we want to put an asterisk by each invalid entry
+ # (see example in prolog).
- # Make the caller's variable name, contained in $var_name, directly
- # accessible to this procedure.
+ # Make the caller's variable name, contained in $var_name, directly accessible to this procedure.
upvar $stack_level $var_name $var_name
# print_list the caller's list to a string.
set printed_var [sprint_list $var_name "" "" 1]
- # Now convert the caller's printed var string to a list for easy
- # manipulation.
+ # Now convert the caller's printed var string to a list for easy manipulation.
set printed_var_list [split $printed_var "\n"]
- # Loop through the erroneous index list and mark corresponding entries in
- # printed_var_list with asterisks.
+ # Loop through the erroneous index list and mark corresponding entries in printed_var_list with asterisks.
foreach ix $invalid_ix_list {
set new_value "[lindex $printed_var_list $ix]*"
set printed_var_list [lreplace $printed_var_list ${ix} ${ix} $new_value]
@@ -177,8 +161,8 @@
append error_message "The following list has one or more invalid values"
append error_message " (marked with \"*\"):\n\n"
append error_message $printed_var
- # Determine whether the caller passed invalid_values or valid_values in
- # order to create appropriate error message.
+ # Determine whether the caller passed invalid_values or valid_values in order to create appropriate error
+ # message.
if { [lindex $args 0] != "" } {
append error_message "\nIt must NOT be any of the following values:\n\n"
set invalid_values [lindex $args 0]
@@ -196,15 +180,13 @@
proc valid_integer { var_name } {
- # If the value of the variable named in var_name is not a valid integer,
- # print an error message and exit the program with a non-zero return code.
+ # If the value of the variable named in var_name is not a valid integer, print an error message and exit
+ # the program with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated.
+ # var_name The name of the variable whose value is to be validated.
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -221,18 +203,15 @@
proc valid_dir_path { var_name { add_slash 1 } } {
- # If the value of the variable named in var_name is not a valid directory
- # path, print an error message and exit the program with a non-zero return
- # code.
+ # If the value of the variable named in var_name is not a valid directory path, print an error message and
+ # exit the program with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated.
- # add_slash If set to 1, this procedure will add a
- # trailing slash to the directory path value.
+ # var_name The name of the variable whose value is to be validated.
+ # add_slash If set to 1, this procedure will add a trailing slash to the directory
+ # path value.
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -253,15 +232,13 @@
proc valid_file_path { var_name } {
- # If the value of the variable named in var_name is not a valid file path,
- # print an error message and exit the program with a non-zero return code.
+ # If the value of the variable named in var_name is not a valid file path, print an error message and exit
+ # the program with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated.
+ # var_name The name of the variable whose value is to be validated.
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -282,8 +259,7 @@
# Prompt user for password and return result.
- # On error, print to stderr and terminate the program with non-zero return
- # code.
+ # On error, print to stderr and terminate the program with non-zero return code.
set prompt\
[string trimright [sprint_varx "Please enter $password_var_name" ""] "\n"]
@@ -320,17 +296,14 @@
proc valid_password { var_name { prompt_user 1 } } {
- # If the value of the variable named in var_name is not a valid password,
- # print an error message and exit the program with a non-zero return code.
+ # If the value of the variable named in var_name is not a valid password, print an error message and exit
+ # the program with a non-zero return code.
# Description of arguments:
- # var_name The name of the variable whose value is to
- # be validated.
- # prompt_user If the variable has a blank value, prompt
- # the user for a value.
+ # var_name The name of the variable whose value is to be validated.
+ # prompt_user If the variable has a blank value, prompt the user for a value.
- # Call get_stack_var_level to relieve the caller of the need for declaring
- # the variable as global.
+ # Call get_stack_var_level to relieve the caller of the need for declaring the variable as global.
set stack_level [get_stack_var_level $var_name]
# Access the variable value.
upvar $stack_level $var_name var_value
@@ -350,29 +323,24 @@
proc process_pw_file_path {pw_file_path_var_name} {
- # Process a password file path parameter by setting or validating the
- # corresponding password variable.
+ # Process a password file path parameter by setting or validating the corresponding password variable.
- # For example, let's say you have an os_pw_file_path parm defined. This
- # procedure will set the global os_password variable.
+ # For example, let's say you have an os_pw_file_path parm defined. This procedure will set the global
+ # os_password variable.
- # If there is no os_password program parm defined, then the pw_file_path
- # must exist and will be validated by this procedure. If there is an
- # os_password program parm defined, then either the os_pw_file_path must be
- # valid or the os_password must be valid. Again, this procedure will verify
- # all of this.
+ # If there is no os_password program parm defined, then the pw_file_path must exist and will be validated
+ # by this procedure. If there is an os_password program parm defined, then either the os_pw_file_path must
+ # be valid or the os_password must be valid. Again, this procedure will verify all of this.
- # When a valid pw_file_path exists, this program will read the password
- # from it and set the global password variable with the value.
- # Finally, this procedure will call valid_password which will prompt user
- # if password has not been obtained by this point.
+ # When a valid pw_file_path exists, this program will read the password from it and set the global
+ # password variable with the value.
+ # Finally, this procedure will call valid_password which will prompt user if password has not been
+ # obtained by this point.
# Description of argument(s):
- # pw_file_path_var_name The name of a global variable that
- # contains a file path which in turn
- # contains a password value. The variable
- # name must end in "pw_file_path" (e.g.
- # "os_pw_file_path").
+ # pw_file_path_var_name The name of a global variable that contains a file path which in turn
+ # contains a password value. The variable name must end in "pw_file_path"
+ # (e.g. "os_pw_file_path").
# Verify that $pw_file_path_var_name ends with "pw_file_path".
if { ! [regexp -expanded "pw_file_path$" $pw_file_path_var_name] } {
@@ -387,8 +355,8 @@
global $pw_file_path_var_name
expand_shell_string $pw_file_path_var_name
- # Get the prefix portion of pw_file_path_var_name which is obtained by
- # stripping "pw_file_path" from the end.
+ # Get the prefix portion of pw_file_path_var_name which is obtained by stripping "pw_file_path" from the
+ # end.
regsub -expanded {pw_file_path$} $pw_file_path_var_name {} var_prefix
# Create password_var_name.
@@ -398,8 +366,7 @@
global longoptions pos_parms
regsub -all ":" "${longoptions} ${pos_parms}" {} parm_names
if { [lsearch -exact parm_names $password_var_name] == -1 } {
- # If no corresponding password program parm has been defined, then the
- # pw_file_path must be valid.
+ # If no corresponding password program parm has been defined, then the pw_file_path must be valid.
valid_file_path $pw_file_path_var_name
}