예제 #1
0
    def ToString(self, error_prefix):
        """Builds error message string escaping it for HTML.

    Args:
      error_prefix: an error prefix.
    Returns:
      HTML escaped error message.
    """
        if error_prefix:
            return utils.HtmlEscape("{0}: {1}".format(
                error_prefix,
                str(self.args[0] if len(self.args) <= 1 else self.args)))
        else:
            return utils.HtmlEscape("Error: {0}".format(
                str(self.args[0] if len(self.args) <= 1 else self.args)))
예제 #2
0
    def getvalue_escaped(self, key, default_val=None):
        """Gets value with special characters HTML-escaped.

    Args:
      key: requested argument.
      default_val: a default value to return if requested argument is not
                   present.
    Returns:
      html-escaped value for requested argument.
    """
        logging.debug("getvalue_escaped() - key: %s", key)

        val = self._getvalue_raw(key, default_val)
        if not val:
            return val

        val = utils.HtmlEscape(val)
        logging.debug("getvalue_escaped() - val: %s", val)
        return val