Skip to content

Commit a988913

Browse files
Merge pull request #1079 from douglasjacobsen/fix-info-formatting
Fix formatting of specs, compilers, and workload groups in info
2 parents 5dd8c80 + ab8c026 commit a988913

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

lib/ramble/ramble/cmd/common/info.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ def _print_verbose_dict_attr(internal_attr, pattern="*", indentation=(" " * 4)):
189189
sub items. These need to be iterated over, and we need to escape existing
190190
characters that would normally be used to color strings.
191191
"""
192-
for name, val in internal_attr.items():
192+
for name, vals in internal_attr.items():
193193
if pattern and not fnmatch.fnmatch(name, pattern):
194194
continue
195195

196-
if isinstance(val, dict):
196+
if isinstance(vals, dict):
197197
color_name = ramble.util.colors.section_title(name)
198198
color.cprint(f"{color_name}:")
199-
for sub_name, sub_val in val.items():
199+
for sub_name, sub_val in vals.items():
200200
# Avoid showing duplicate names for variables
201201
if isinstance(sub_val, WorkloadVariable) and sub_name == sub_val.name:
202202
to_print = f"{indentation}{sub_val}"
@@ -209,8 +209,24 @@ def _print_verbose_dict_attr(internal_attr, pattern="*", indentation=(" " * 4)):
209209
escaped_sub_val = sub_val.replace("@", "@@")
210210
color.cprint(f"{indentation}{color_sub_name}: {escaped_sub_val}")
211211
color.cprint("")
212+
elif isinstance(vals, set):
213+
color_name = ramble.util.colors.section_title(name)
214+
color.cprint(f"{color_name}:")
215+
for sub_name in vals:
216+
# Avoid showing duplicate names for variables
217+
color_sub_name = ramble.util.colors.nested_1(sub_name)
218+
to_print = f"{indentation}{color_sub_name}"
219+
try:
220+
color.cprint(to_print)
221+
except color.ColorParseError:
222+
escaped_sub_name = ramble.util.colors.nested_1(sub_name.replace("@", "@@"))
223+
color.cprint(f"{indentation}{escaped_sub_name}")
224+
color.cprint("")
225+
elif isinstance(vals, list):
226+
for val in vals:
227+
color.cprint(f"{val.as_str()}")
212228
else:
213-
color.cprint(f"{str(val)}")
229+
color.cprint(f"{str(vals)}")
214230

215231

216232
# Attributes that need special print functions

lib/ramble/ramble/util/spec_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def as_str(self, indent=0):
8080
color_key = ramble.util.colors.nested_1(key)
8181
escaped_val = val.replace("@", "@@")
8282
output += f"{indentation}{color_key}: {escaped_val}\n"
83+
if self.when:
84+
output += ramble.util.colors.nested_2(f"\n{indentation}When:\n")
85+
for condition in self.when:
86+
output += f"{indentation} {condition}\n"
8387
return output
8488

8589
def __str__(self):

0 commit comments

Comments
 (0)