Commit 377a2412 authored by Alexei Svitkine's avatar Alexei Svitkine Committed by Commit Bot

Update action_utils.py from internal version.

Some small fixes and Py3 compatibility.

Bug: None
Change-Id: I09855299135799527dbcf4d0070a2ce9d9147d6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872564
Auto-Submit: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708795}
parent ab025fb7
...@@ -9,6 +9,10 @@ infrastructure. Any changes to this file should also be done (manually) to the ...@@ -9,6 +9,10 @@ infrastructure. Any changes to this file should also be done (manually) to the
internal copy. Please contact tools/metrics/OWNERS for more details. internal copy. Please contact tools/metrics/OWNERS for more details.
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class Error(Exception): class Error(Exception):
pass pass
...@@ -109,8 +113,8 @@ def CreateActionsFromSuffixes(actions_dict, action_suffix_nodes): ...@@ -109,8 +113,8 @@ def CreateActionsFromSuffixes(actions_dict, action_suffix_nodes):
# If action_to_suffixes_dict is not empty by the end, we have missing actions. # If action_to_suffixes_dict is not empty by the end, we have missing actions.
if action_to_suffixes_dict: if action_to_suffixes_dict:
raise UndefinedActionItemError('Following actions are missing: %s.' raise UndefinedActionItemError('Following actions are missing: %s.' %
%(action_to_suffixes_dict.keys())) (list(action_to_suffixes_dict.keys())))
def _CreateActionToSuffixesDict(action_suffix_nodes): def _CreateActionToSuffixesDict(action_suffix_nodes):
...@@ -173,7 +177,7 @@ def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict): ...@@ -173,7 +177,7 @@ def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict):
"""Creates new actions with action-suffix pairs and adds them to actions_dict. """Creates new actions with action-suffix pairs and adds them to actions_dict.
For every key (action name) in action_to_suffixes_dict, This function looks For every key (action name) in action_to_suffixes_dict, This function looks
to see wether it exists in actions_dict. If so it combines the Action object to see whether it exists in actions_dict. If so it combines the Action object
from actions_dict with all the Suffix objects from action_to_suffixes_dict to from actions_dict with all the Suffix objects from action_to_suffixes_dict to
create new Action objects. New Action objects are added to actions_dict and create new Action objects. New Action objects are added to actions_dict and
the action name is removed from action_to_suffixes_dict. the action name is removed from action_to_suffixes_dict.
...@@ -187,7 +191,7 @@ def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict): ...@@ -187,7 +191,7 @@ def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict):
True if any new action was added, False otherwise. True if any new action was added, False otherwise.
""" """
expanded_actions = set() expanded_actions = set()
for action_name, suffixes in action_to_suffixes_dict.iteritems(): for action_name, suffixes in action_to_suffixes_dict.items():
if action_name in actions_dict: if action_name in actions_dict:
existing_action = actions_dict[action_name] existing_action = actions_dict[action_name]
for suffix in suffixes: for suffix in suffixes:
...@@ -220,8 +224,8 @@ def _CreateActionFromSuffix(actions_dict, action, suffix): ...@@ -220,8 +224,8 @@ def _CreateActionFromSuffix(actions_dict, action, suffix):
else: else:
(before, dot, after) = action.name.partition('.') (before, dot, after) = action.name.partition('.')
if not after: if not after:
raise InvalidAffecteddActionNameError("Action name '%s' must contain a " raise InvalidAffecteddActionNameError(
"'.'.", action.name) "Action name '%s' must contain a '.'." % action.name)
new_action_name = before + dot + suffix.name + suffix.separator + after new_action_name = before + dot + suffix.name + suffix.separator + after
new_action_description = action.description + ' ' + suffix.description new_action_description = action.description + ' ' + suffix.description
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment