Changes to gen_misc.py/gen_print.py.
- The following functions are new:
- which
- dft
- get_mod_global
- global_default
- file_to_list
- sprint_varx:
- Added support for terse format for dictionaries.
Change-Id: Ie6daeb7d78d9c51d40f5bf5c400de1e2d640e606
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_print.py b/lib/gen_print.py
index 135218e..643a3be 100755
--- a/lib/gen_print.py
+++ b/lib/gen_print.py
@@ -600,7 +600,7 @@
value_format = "%s"
format_string = "%" + str(loc_col1_indent) + "s%-" \
+ str(loc_col1_width) + "s" + value_format + trailing_char
- return format_string % ("", var_name + ":", var_value)
+ return format_string % ("", str(var_name) + ":", var_value)
else:
# The data type is complex in the sense that it has subordinate parts.
format_string = "%" + str(loc_col1_indent) + "s%s\n"
@@ -636,8 +636,13 @@
if ix == length:
loc_trailing_char = trailing_char
if hex:
+ # 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)
buffer += sprint_varx(key, value,
- hex, loc_col1_indent, loc_col1_width,
+ loc_hex, loc_col1_indent,
+ loc_col1_width,
loc_trailing_char)
else:
buffer += sprint_varx(var_name + "[" + key + "]", value,
@@ -671,7 +676,7 @@
loc_col1_width = loc_col1_width - loc_col1_indent
format_string = "%" + str(loc_col1_indent) + "s%-" \
+ str(loc_col1_width) + "s" + value_format + trailing_char
- return format_string % ("", var_name + ":", var_value)
+ return format_string % ("", str(var_name) + ":", var_value)
return buffer