def safeCodeType(self):  # pylint: disable=g-bad-name
        """Expose this in template using the template naming convention.

    Just redirect to safe_code_type.

    Returns:
      (str) The evaluated code type.
    """
        return MarkSafe(self.safe_code_type)
    def packageRelativeClassName(self):  # pylint: disable=g-bad-name
        """Returns the class name for this object relative to its package.

    Walks up the parent chain building a fully qualified class name.

    Returns:
      (str) The class name of this object.
    """
        return MarkSafe(self.RelativeClassName(None))
    def codeType(self):  # pylint: disable=g-bad-name
        """Accessor for codeType for use in templates.

    If the template value for codeType was explicitly set, return that,
    otherwise use the code_type member. This is only safe to call for code
    objects which implement code_type.

    Returns:
      (str) the value for codeType
    """
        return MarkSafe(self.GetTemplateValue('codeType') or self.code_type)
    def ValidateAndSanitizeComment(cls, comment):
        """Remove unsafe constructions from a string and make it safe in templates.

    Make sure a string intended as a comment has only safe constructs in it and
    then make it as safe to expand directly in a template. If it fails the test,
    return an empty string.

    Args:
      comment: (str) A string which is expected to be a documentation comment.

    Returns:
      (str) The comment with HTML-unsafe constructions removed.
    """
        return MarkSafe(cls._validator.ValidateAndSanitizeComment(comment))
Exemplo n.º 5
0
  def fullClassName(self):  # pylint: disable=g-bad-name
    """Returns the fully qualified class name for this object.

    This property can only be used during template expansion.  Walks up the
    parent chain building a fully qualified class name. If the object is in a
    module, include the module name.

    Returns:
      (str) The class name of this object.
    """
    module = self.module
    if module:
      class_name_delimiter = self.language_model.class_name_delimiter
      return module.name + class_name_delimiter + self.RelativeClassName(None)
    return MarkSafe(self.RelativeClassName(None))
Exemplo n.º 6
0
  def codeName(self):  # pylint: disable=g-bad-name
    """Returns a language appropriate name for this object.

    This property should only be used during template expansion. It is computed
    once, using the LanguageModel in play, and then that value is cached.

    Returns:
      (str) a name for an instance of this object.
    """
    # Note that if code name is in self._def_dict (and hence GetTemplateValue
    # returns something) then this property won't be called during template
    # expansion at all.  Therefore, the change this makes -- marking codeName
    # safe -- may never take place at all.
    code_name = self.GetTemplateValue('codeName')
    if not code_name:
      code_name = self.values['wireName']
      if self.language_model:
        code_name = self.language_model.ToMemberName(code_name, self._api)
    code_name = MarkSafe(code_name)
    self.SetTemplateValue('codeName', code_name)
    return code_name