Skip to content

Commit

Permalink
Merge pull request #801 from linsword13/mod_var
Browse files Browse the repository at this point in the history
Avoid showing duplicate modifier variable names in info print
  • Loading branch information
linsword13 authored Dec 13, 2024
2 parents 61930c3 + 63fc75c commit 44bd062
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/ramble/ramble/cmd/common/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ramble.repository

from ramble.util.logger import logger
from ramble.workload import WorkloadVariable

import enum

Expand Down Expand Up @@ -240,9 +241,14 @@ def print_single_attribute(obj, attr, verbose=False, pattern="*", format=support
color_name = ramble.util.colors.section_title(name)
color.cprint(f"{color_name}:")
for sub_name, sub_val in val.items():
color_sub_name = ramble.util.colors.nested_1(sub_name)
# Avoid showing duplicate names for variables
if isinstance(sub_val, WorkloadVariable) and sub_name == sub_val.name:
to_print = f"{indentation}{sub_val}"
else:
color_sub_name = ramble.util.colors.nested_1(sub_name)
to_print = f"{indentation}{color_sub_name}: {sub_val}"
try:
color.cprint(f"{indentation}{color_sub_name}: {sub_val}")
color.cprint(to_print)
except color.ColorParseError:
escaped_sub_val = sub_val.replace("@", "@@")
color.cprint(f"{indentation}{color_sub_name}: {escaped_sub_val}")
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def as_str(self, n_indent: int = 0):

print_attrs = ["Description", "Default", "Values"]

out_str = "\n"
out_str = rucolor.nested_2(f"{indentation}{self.name}:\n")
for print_attr in print_attrs:
name = print_attr
if print_attr == "Values":
Expand Down

0 comments on commit 44bd062

Please sign in to comment.