Skip to content

Commit

Permalink
roll display_dicts result into ItemStatus so it’s available for `bw v…
Browse files Browse the repository at this point in the history
…erify`

fixes #376
  • Loading branch information
trehn committed Dec 31, 2017
1 parent c5bfb35 commit 6b0ce58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions bundlewrap/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ItemStatus(object):
fixing and what's broken.
"""

def __init__(self, cdict, sdict):
def __init__(self, cdict, sdict, display_dicts):
self.cdict = cdict
self.sdict = sdict
self.keys_to_fix = []
Expand All @@ -64,6 +64,12 @@ def __init__(self, cdict, sdict):
if not self.must_be_deleted and not self.must_be_created:
self.keys_to_fix = diff_keys(cdict, sdict)

self.display_cdict, self.display_sdict, self.display_keys_to_fix = display_dicts(
copy(cdict),
copy(sdict),
copy(self.keys_to_fix),
)

def __repr__(self):
return "<ItemStatus correct:{}>".format(self.correct)

Expand Down Expand Up @@ -497,12 +503,11 @@ def apply(
elif status_before.must_be_deleted:
question_text = _("Found on node. Will be removed.")
else:
cdict, sdict, display_keys_to_fix = self.display_dicts(
copy(self.cached_cdict),
copy(status_before.sdict),
copy(keys_to_fix),
question_text = self.ask(
status_before.display_cdict,
status_before.display_sdict,
status_before.display_keys_to_fix,
)
question_text = self.ask(cdict, sdict, display_keys_to_fix)
if self.comment:
question_text += format_comment(self.comment)
question = wrap_question(
Expand Down Expand Up @@ -643,7 +648,7 @@ def get_status(self, cached=True):
)):
if not cached:
del self._cache['cached_sdict']
return ItemStatus(self.cached_cdict, self.cached_sdict)
return ItemStatus(self.cached_cdict, self.cached_sdict, self.display_dicts)

def hash(self):
return hash_statedict(self.cached_cdict)
Expand Down
2 changes: 1 addition & 1 deletion bundlewrap/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def handle_result(task_id, return_value, duration):
elif item_status.must_be_deleted:
changes_text = _("remove")
else:
changes_text = ", ".join(sorted(item_status.keys_to_fix))
changes_text = ", ".join(sorted(item_status.display_keys_to_fix))
io.stderr("{x} {node} {bundle} {item} ({changes})".format(
bundle=bold(bundle_name),
changes=changes_text,
Expand Down

0 comments on commit 6b0ce58

Please sign in to comment.