Skip to content

Commit

Permalink
squash: some changes, renamed callback, colors
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Aug 21, 2023
1 parent 79725a7 commit ff6c807
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 25 additions & 11 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,30 @@ def create_adjust_callback(logger: tmt.log.Logger) -> fmf.base.AdjustCallback:
def callback(
node: fmf.Tree,
rule: _RawAdjustRule,
applied: bool) -> None:
if applied is False:
return
applied: Optional[bool]) -> None:
if applied is None:
logger.verbose(
f"Adjust rule **skipped** on '{node.name}'",
tmt.utils.format_value(rule, key_color='green'),
color='cyan',
level=3,
topic=tmt.log.Topic.ADJUST_DECISIONS)

elif applied is False:
logger.verbose(
f"Adjust rule **not applied** to '{node.name}'",
tmt.utils.format_value(rule, key_color='green'),
color='red',
level=3,
topic=tmt.log.Topic.ADJUST_DECISIONS)

logger.verbose(
f"Adjust rule applied to '{node.name}'",
tmt.utils.format_value(rule, key_color='green'),
color='cyan',
level=3,
topic=tmt.log.Topic.ADJUST_RULINGS)
else:
logger.verbose(
f"Adjust rule **applied** to '{node.name}'",
tmt.utils.format_value(rule, key_color='green'),
color='green',
level=3,
topic=tmt.log.Topic.ADJUST_DECISIONS)

return callback

Expand Down Expand Up @@ -2615,7 +2629,7 @@ def tree(self) -> fmf.Tree:
# Adjust metadata for current fmf context
self._tree.adjust(
fmf.context.Context(**self._fmf_context),
on_rule=create_adjust_callback(self._logger))
decision_callback=create_adjust_callback(self._logger))
return self._tree

@tree.setter
Expand Down Expand Up @@ -3906,7 +3920,7 @@ def resolve_dynamic_ref(
raise tmt.utils.FileError("Cannot get plan fmf context to evaluate dynamic ref.")
reference_tree.adjust(
fmf.context.Context(**plan._fmf_context),
on_rule=create_adjust_callback(logger))
decision_callback=create_adjust_callback(logger))
# Also temporarily build a plan so that env and context variables are expanded
Plan(logger=logger, node=reference_tree, run=plan.my_run, skip_validation=True)
ref = reference_tree.get("ref")
Expand Down
2 changes: 1 addition & 1 deletion tmt/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
class Topic(enum.Enum):
KEY_NORMALIZATION = 'key-normalization'
CLI_INVOCATIONS = 'cli-invocations'
ADJUST_RULINGS = 'adjust-rulings'
ADJUST_DECISIONS = 'adjust-decisions'


DEFAULT_TOPICS: Set[Topic] = set()
Expand Down

0 comments on commit ff6c807

Please sign in to comment.