Replace @body with YAML

 @return [String] A string containing response as YAML
483127
def to_yaml!
      @body = YAML.dump(to_h)
    rescue => err
      raise ParseError.new(err), err
    end
931137
def normalize(string)
      new_body = normalize_entities(string)
      # Fix mismatched tags. Yes, it's faster to do it per-message
      # than all at once.
      new_body = Pipio::TagBalancer.new(new_body).balance
      if @sender_alias[0,3] == '***'
        # "***<alias>" is what pidgin sets as the alias for a /me action
        @sender_alias.slice!(0,3)
        new_body = "*#{new_body}*"
      end

      new_body
    end
543321
def body(self, environ, file_like):
        
        variables = environ.copy()
        variables.update(self.variables)
        template = string.Template(file_like.read())
        if self.safe is True:
            return [template.safe_substitute(variables)]
        else:
            return [template.substitute(variables)]
654269
def merge!(response)
      return self if response == self
      if Rack::Response === response
        response = [response.status, response.header, response]
      end
      self.status, self.body = response[0], response[2]
      self.header.merge!(response[1])
      self
    end
964202
def format_response(status, body_object, headers={})
      if status == 204
        body = ''
      else
        body = case response_media_type
        when 'application/json'
          JSON.pretty_generate(body_object)
        when 'application/x-www-form-urlencoded'
          URI.encode_www_form(body_object)
        when 'application/xml'
          body_object.to_s
        when 'text/plain'
          body_object
        else
          # :nocov:
          raise NotImplementedError, "unsupported response media type #{response_media_type}"
          # :nocov:
        end
      end
      [status, headers.merge({'Content-Type' => response_media_type}), [body]]
    end
834724
def to_s
      response_data[:content].values.inject("") do |res, verse|
        res += " " unless res.empty?
        res + verse[:verse].join(" ")
      end

    rescue ScriptureLookup::Error
      raise
    rescue => error
      raise ScriptureLookup::Error
    end
78162
def yaml_to_str(data: Mapping) -> str:
    
    return yaml.dump(data, Dumper=ruamel.yaml.RoundTripDumper)
742288
def normalize_yaml(yaml):
    
    if isinstance(yaml, list):
        # Normalize the roles YAML data
        normalized_yaml = [(x['name'], x['src'], x.get('version', 'HEAD'))
                           for x in yaml]
    else:
        # Extract the project names from the roles YAML and create a list of
        # tuples.
        projects = [x[:-9] for x in yaml.keys() if x.endswith('git_repo')]
        normalized_yaml = []
        for project in projects:
            repo_url = yaml['{0}_git_repo'.format(project)]
            commit_sha = yaml['{0}_git_install_branch'.format(project)]
            normalized_yaml.append((project, repo_url, commit_sha))

    return normalized_yaml
297831
def encode(response)
      [200,
       { Rack::CONTENT_TYPE => 'text/html',
         Rack::CONTENT_LENGTH => response.size.to_s },
       [response]]
    end
462995
def parse_yaml(file)
      file_content = File.exist?(file) ? ERB.new(File.read(file)).result : '---'

      config = YAML.load(file_content) || {}
      env    = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['APP_CONFIG_ENV']

      config_from config['default'], config[env]
    end
96768
def yaml_processor(entity):
    '''
    
    '''
    if six.PY2:
        body = entity.fp.read()
    else:
        # https://github.com/cherrypy/cherrypy/pull/1572
        contents = BytesIO()
        body = entity.fp.read(fp_out=contents)
        contents.seek(0)
        body = salt.utils.stringutils.to_unicode(contents.read())
    try:
        cherrypy.serving.request.unserialized_data = salt.utils.yaml.safe_load(body)
    except ValueError:
        raise cherrypy.HTTPError(400, 'Invalid YAML document')

    cherrypy.serving.request.raw_body = body
693699
def result(body)
      begin
        ActiveSupport::JSON.decode body
      rescue => e
        {
          code: 502,
          msg: '内容解析错误',
          detail: e.to_s
        }
      end
    end
366324
def to_yaml(cls, dumper, data):
        
        return dumper.represent_yaml_object(cls.yaml_tag, data, cls,
                flow_style=cls.yaml_flow_style)
1354456
def _state_data_to_yaml_string(data, whitelist=None, blacklist=None):
    '''
    
    '''
    y = {}
    if blacklist is None:
        # TODO: use salt defined STATE_REQUISITE_IN_KEYWORDS  STATE_RUNTIME_KEYWORDS  STATE_INTERNAL_KEYWORDS
        blacklist = ['__env__', '__id__', '__sls__', 'fun', 'name', 'context', 'order', 'state', 'require', 'require_in', 'watch', 'watch_in']
    kset = set(data.keys())
    if blacklist:
        kset -= set(blacklist)
    if whitelist:
        kset &= set(whitelist)
    for k in kset:
        y[k] = data[k]
    if not y:
        return None
    return salt.utils.yaml.safe_dump(y, default_flow_style=False)
1121253
def parse_yaml(self, y):
        ''''''
        self._reset()
        self.id = y['id']
        self.path_uri = y['pathUri']
        if 'activeConfigurationSet' in y:
            self.active_configuration_set = y['activeConfigurationSet']
        else:
            self.active_configuration_set = ''
        self.instance_name = y['instanceName']
        self.compositeType = comp_type.from_string(y['compositeType'])
        required = y['isRequired']
        if required == True or required == 'true' or required == '1':
            self.is_required = True
        else:
            self.is_required = False
        if RTS_EXT_NS_YAML + 'comment' in y:
            self.comment = y[RTS_EXT_NS_YAML + 'comment']
        self.visible = False
        if RTS_EXT_NS_YAML + 'visible' in y:
            visible = y.get(RTS_EXT_NS_YAML + 'visible')
            if visible == True or visible == 'true' or visible == 'True':
                self.visible = True

        # Get the children
        if 'dataPorts' in y:
            for p in y.get('dataPorts'):
                self._data_ports.append(DataPort().parse_yaml(p))
        if 'servicePorts' in y:
            for p in y.get('servicePorts'):
                self._service_ports.append(ServicePort().parse_yaml(p))
        if 'configurationSets' in y:
            for p in y.get('configurationSets'):
                self._config_sets.append(ConfigurationSet().parse_yaml(p))
        if 'executionContexts' in y:
            for p in y.get('executionContexts'):
                self._exec_contexts.append(ExecutionContext().parse_yaml(p))
        if 'participants' in y:
            for p in y.get('participants'):
                self._participants.append(Participant().parse_yaml(p))

        # Extended profile children
        if RTS_EXT_NS_YAML + 'location' in y:
            l = y[RTS_EXT_NS_YAML + 'location']
            self._location = Location().parse_yaml(l)
        if RTS_EXT_NS_YAML + 'properties' in y:
            for p in y.get(RTS_EXT_NS_YAML + 'properties'):
                if 'value' in p:
                    value = p['value']
                else:
                    value = None
                self._properties[p['name']] = value

        return self
503670
def parse_response(response:, params: nil, body: {})
      if response.code < 299
        body[:data] = parse_json(response.body)
        body[:success] = true
      else
        error = write_error_message(response)
        body[:error] = error
        body[:success] = false
      end
      body[:code] = response.code
      body.merge!(raw: { body: response.body, params: params })
    end
974696
def yaml_encode(data):
    '''
    
    '''
    yrepr = yaml.representer.SafeRepresenter()
    ynode = yrepr.represent_data(data)
    if not isinstance(ynode, yaml.ScalarNode):
        raise TypeError(
            "yaml_encode() only works with YAML scalar data;"
            " failed for {0}".format(type(data))
        )

    tag = ynode.tag.rsplit(':', 1)[-1]
    ret = ynode.value

    if tag == "str":
        ret = yaml_dquote(ynode.value)

    return ret