Formatted python files to follow PEP 8 python code standards.
- Changed the python files in the openbmc-test-automation
directory to conform to python code style standards with
the exception of E402 and E501.
- Resolves openbmc/openbmc-test-automation#1308
Change-Id: I109995c2d248f5a6bb2c0e3c76a6144c8f3aac2e
Signed-off-by: Joy Onyerikwu <onyekachukwu.joy.onyerikwu@ibm.com>
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_print.py b/lib/gen_print.py
index 0de4489..ed254fc 100755
--- a/lib/gen_print.py
+++ b/lib/gen_print.py
@@ -27,7 +27,7 @@
# are in a robot environment. The following try block should confirm that.
try:
var_value = BuiltIn().get_variable_value("${SUITE_NAME}", "")
- except:
+ except BaseException:
robot_env = 0
except ImportError:
robot_env = 0
@@ -203,10 +203,10 @@
os.environ.get('GET_ARG_NAME_SHOW_SOURCE', 0))
if stack_frame_ix < 1:
- print_error("Programmer error - Variable \"stack_frame_ix\" has an" +
- " invalid value of \"" + str(stack_frame_ix) + "\". The" +
- " value must be an integer that is greater than or equal" +
- " to 1.\n")
+ print_error("Programmer error - Variable \"stack_frame_ix\" has an"
+ + " invalid value of \"" + str(stack_frame_ix) + "\". The"
+ + " value must be an integer that is greater than or equal"
+ + " to 1.\n")
return
if local_debug:
@@ -225,12 +225,12 @@
frame, filename, cur_line_no, function_name, lines, index = \
inspect.stack()[stack_frame_ix]
except IndexError:
- print_error("Programmer error - The caller has asked for" +
- " information about the stack frame at index \"" +
- str(stack_frame_ix) + "\". However, the stack" +
- " only contains " + str(len(inspect.stack())) +
- " entries. Therefore the stack frame index is out" +
- " of range.\n")
+ print_error("Programmer error - The caller has asked for"
+ + " information about the stack frame at index \""
+ + str(stack_frame_ix) + "\". However, the stack"
+ + " only contains " + str(len(inspect.stack()))
+ + " entries. Therefore the stack frame index is out"
+ + " of range.\n")
return
if filename != "<string>":
break
@@ -308,11 +308,11 @@
# The call to the function could be encased in a recast (e.g.
# int(func_name())).
- recast_regex = "([^ ]+\([ ]*)?"
- import_name_regex = "([a-zA-Z0-9_]+\.)?"
+ recast_regex = "([^ ]+\\([ ]*)?"
+ import_name_regex = "([a-zA-Z0-9_]+\\.)?"
func_name_regex = recast_regex + import_name_regex + "(" +\
'|'.join(aliases) + ")"
- pre_args_regex = ".*" + func_name_regex + "[ ]*\("
+ pre_args_regex = ".*" + func_name_regex + "[ ]*\\("
# Search backward through source lines looking for the calling function
# name.
@@ -325,9 +325,9 @@
found = True
break
if not found:
- print_error("Programmer error - Could not find the source line with" +
- " a reference to function \"" + real_called_func_name +
- "\".\n")
+ print_error("Programmer error - Could not find the source line with"
+ + " a reference to function \"" + real_called_func_name
+ + "\".\n")
return
# Search forward through the source lines looking for a line whose
@@ -375,7 +375,8 @@
lvalues[ix] = lvalue
ix += 1
lvalue_prefix_regex = "(.*=[ ]+)?"
- called_func_name_regex = lvalue_prefix_regex + func_name_regex + "[ ]*\(.*"
+ called_func_name_regex = lvalue_prefix_regex + func_name_regex +\
+ "[ ]*\\(.*"
called_func_name = re.sub(called_func_name_regex, "\\4", composite_line)
arg_list_etc = "(" + re.sub(pre_args_regex, "", composite_line)
if local_debug:
@@ -805,7 +806,7 @@
var_value & 0xffffffff)
else:
return format_string % ("", str(var_name) + ":", var_value)
- elif type(var_value) is type:
+ elif isinstance(var_value, type):
return sprint_varx(var_name, str(var_value).split("'")[1], hex,
loc_col1_indent, loc_col1_width, trailing_char,
key_list)
@@ -821,20 +822,20 @@
ix = 0
loc_trailing_char = "\n"
type_is_dict = 0
- if type(var_value) is dict:
+ if isinstance(var_value, dict):
type_is_dict = 1
try:
- if type(var_value) is collections.OrderedDict:
+ if isinstance(var_value, collections.OrderedDict):
type_is_dict = 1
except AttributeError:
pass
try:
- if type(var_value) is DotDict:
+ if isinstance(var_value, DotDict):
type_is_dict = 1
except NameError:
pass
try:
- if type(var_value) is NormalizedDict:
+ if isinstance(var_value, NormalizedDict):
type_is_dict = 1
except NameError:
pass
@@ -851,7 +852,7 @@
# Since hex is being used as a format type, we want it
# turned off when processing integer dictionary values so
# it is not interpreted as a hex indicator.
- loc_hex = not (type(value) is int)
+ loc_hex = not (isinstance(value, int))
buffer += sprint_varx("[" + key + "]", value,
loc_hex, loc_col1_indent,
loc_col1_width,
@@ -870,7 +871,7 @@
buffer += sprint_varx(var_name + "[" + str(key) + "]", value,
hex, loc_col1_indent, loc_col1_width,
loc_trailing_char, key_list)
- elif type(var_value) is argparse.Namespace:
+ elif isinstance(var_value, argparse.Namespace):
for key in var_value.__dict__:
ix += 1
if ix == length:
@@ -956,7 +957,7 @@
var_name = get_arg_name(None, parm_num, stack_frame)
# See if parm 1 is to be interpreted as "indent".
try:
- if type(int(var_name)) is int:
+ if isinstance(int(var_name), int):
indent = int(var_name)
args_list.pop(0)
parm_num += 1
@@ -966,7 +967,7 @@
var_name = get_arg_name(None, parm_num, stack_frame)
# See if parm 1 is to be interpreted as "col1_width".
try:
- if type(int(var_name)) is int:
+ if isinstance(int(var_name), int):
loc_col1_width = int(var_name)
args_list.pop(0)
parm_num += 1
@@ -976,7 +977,7 @@
var_name = get_arg_name(None, parm_num, stack_frame)
# See if parm 1 is to be interpreted as "hex".
try:
- if type(int(var_name)) is int:
+ if isinstance(int(var_name), int):
hex = int(var_name)
args_list.pop(0)
parm_num += 1
@@ -1197,8 +1198,8 @@
if robot_env:
suite_name = BuiltIn().get_variable_value("${suite_name}")
- buffer += sindent(sprint_time("Running test suite \"" + suite_name +
- "\".\n"), indent)
+ buffer += sindent(sprint_time("Running test suite \"" + suite_name
+ + "\".\n"), indent)
buffer += sindent(sprint_time() + "Running " + pgm_name + ".\n", indent)
buffer += sindent(sprint_time() + "Program parameter values, etc.:\n\n",
@@ -1220,10 +1221,10 @@
username = "root"
else:
username = "?"
- buffer += sprint_varx("uid", userid_num + " (" + username +
- ")", 0, indent, loc_col1_width)
- buffer += sprint_varx("gid", str(os.getgid()) + " (" +
- str(grp.getgrgid(os.getgid()).gr_name) + ")", 0,
+ buffer += sprint_varx("uid", userid_num + " (" + username
+ + ")", 0, indent, loc_col1_width)
+ buffer += sprint_varx("gid", str(os.getgid()) + " ("
+ + str(grp.getgrgid(os.getgid()).gr_name) + ")", 0,
indent, loc_col1_width)
buffer += sprint_varx("host_name", socket.gethostname(), 0, indent,
loc_col1_width)
@@ -1516,7 +1517,6 @@
def get_stack_var(var_name,
default="",
init_stack_ix=2):
-
r"""
Starting with the caller's stack level, search upward in the call stack,
for a variable named var_name and return its value. If the variable
@@ -1548,8 +1548,8 @@
"""
return next((frame[0].f_locals[var_name]
- for frame in inspect.stack()[init_stack_ix:]
- if var_name in frame[0].f_locals), default)
+ for frame in inspect.stack()[init_stack_ix:]
+ if var_name in frame[0].f_locals), default)
# hidden_text is a list of passwords which are to be replaced with asterisks
@@ -1707,8 +1707,8 @@
# Templates for the various print wrapper functions.
print_func_template = \
[
- " <mod_qualifier>gp_print(<mod_qualifier>replace_passwords(" +
- "<call_line>), stream='<output_stream>')"
+ " <mod_qualifier>gp_print(<mod_qualifier>replace_passwords("
+ + "<call_line>), stream='<output_stream>')"
]
qprint_func_template = \
@@ -1718,8 +1718,8 @@
dprint_func_template = \
[
- " if not int(<mod_qualifier>get_var_value(None, 0, \"debug\")):" +
- " return"
+ " if not int(<mod_qualifier>get_var_value(None, 0, \"debug\")):"
+ + " return"
] + print_func_template
lprint_func_template = \