Пример #1
0
  def _GetProcessedAction(self, owner, description, obsolete,
                          not_user_triggered=NO_VALUE, new_actions=[],
                          comment=NO_VALUE):
    """Forms an actions XML string and returns it after processing.

    It parses the original XML string, adds new user actions (if there is any),
    and pretty prints it.

    Args:
      owner: the owner tag to be inserted in the original XML string.
      description: the description tag to be inserted in the original XML
        string.
      obsolete: the obsolete tag to be inserted in the original XML string.
      new_actions: optional. List of new user actions' names to be inserted.
      comment: the comment tag to be inserted in the original XML string.

    Returns:
      An updated and pretty-printed action XML string.
    """
    # Form the actions.xml mock content based on the input parameters.
    current_xml = ACTIONS_XML.format(owners=owner, description=description,
                                     obsolete=obsolete, comment=comment,
                                     not_user_triggered=not_user_triggered)
    actions, actions_dict, comments = extract_actions.ParseActionFile(
        current_xml)
    for new_action in new_actions:
      actions.add(new_action)
    return extract_actions.PrettyPrint(actions, actions_dict, comments)
Пример #2
0
  def _GetProcessedActionFromActionsXMLString(self, actions_xml):
    """parses the given actions XML string and pretty prints it.

    Args:
      actions_xml: actions XML string.

    Returns:
      An updated and pretty-printed actions XML string.
    """
    actions, actions_dict, comments = extract_actions.ParseActionFile(
        actions_xml)
    return extract_actions.PrettyPrint(actions, actions_dict, comments)
Пример #3
0
    def _PrettyPrintActionsXML(self, actions_xml):
        """Parses the given actions XML and pretty prints it.

    Args:
      actions_xml: actions XML string.

    Returns:
      A pretty-printed actions XML string.
    """
        actions_dict, comments, suffixes = extract_actions.ParseActionFile(
            actions_xml)
        return extract_actions.PrettyPrint(actions_dict, comments, suffixes)
Пример #4
0
    def _ExpandSuffixesInActionsXML(self, actions_xml):
        """Parses the given actions XML, expands suffixes and pretty prints it.

    Args:
      actions_xml: actions XML string.

    Returns:
      An updated and pretty-printed actions XML string with suffixes expanded.
    """
        actions_dict, comments, suffixes = extract_actions.ParseActionFile(
            actions_xml)
        # Clear suffixes and mark actions as not coming from suffixes, so that
        # the returned XML file is the expanded one.
        suffixes = []
        for action in actions_dict.itervalues():
            action.from_suffix = False
        return extract_actions.PrettyPrint(actions_dict, comments, suffixes)