Convert a given value to a YAML string.
1118
def to_yaml(value) -> str:
    """"""
    stream = yaml.io.StringIO()
    dumper = ConfigDumper(stream, default_flow_style=True, width=sys.maxsize)
    val = None
    try:
        dumper.open()
        dumper.represent(value)
        val = stream.getvalue().strip()
        dumper.close()
    finally:
        dumper.dispose()

    return val
267418
def to_yaml
      require 'yaml'
      trackers_export = @trackers.reduce({}) do |export, tracker|
        export[tracker.title] = tracker.to_yaml_object; export
      end
      YAML.dump(trackers_export)
    end
711644
def _encode_dict_as_string(value):
        """"""
        # Strip the first and last newlines
        if value.startswith("{\n"):
            value = "{" + value[2:]
        if value.endswith("\n}"):
            value = value[:-2] + "}"
        # escape double quotes and newlines
        return value.replace('"', '\\"').replace("\\n", "\\\\n").replace("\n", "\\n")
41753
def parse_yaml(self, y):
        '''

        '''
        self.name = y['name']
        if 'data' in y:
            self.data = y['data']
        else:
            self.data = ''
        return self
975048
def build_from_yamlstr(cls, yamlstr):
        
        top_dict = yaml.safe_load(yamlstr)
        coordsys = top_dict.pop('coordsys')
        output_list = []
        for e_key, e_dict in sorted(top_dict.items()):
            if e_key == 'coordsys':
                continue
            e_dict = top_dict[e_key]
            e_dict['coordsys'] = coordsys
            output_list += cls.build_from_energy_dict(e_key, e_dict)
        return output_list
319792
function(value)
	{
		var result = null;
		value = this.trim(value);

		if ( 0 == value.length )
		{
			return '';
		}

		switch ( value.charAt(0) )
		{
			case '[':
				result = this.parseSequence(value);
				break;
			case '{':
				result = this.parseMapping(value);
				break;
			default:
				result = this.parseScalar(value);
		}

		// some comment can end the scalar
		if ( value.substr(this.i+1).replace(/^\s*#.*$/, '') != '' ) {
		    console.log("oups "+value.substr(this.i+1));
			throw new YamlParseException('Unexpected characters near "'+value.substr(this.i)+'".');
		}

		return result;
	}
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
1254959
def dump(data, stream=None, **kwargs):
    '''
    
    '''
    if 'allow_unicode' not in kwargs:
        kwargs['allow_unicode'] = True
    return yaml.dump(data, stream, **kwargs)
963495
def toString(value):
        
        if isinstance(value, basestring):
            return value
        elif type(value) in [np.string_, np.str_]:
            return str(value)
        elif type(value) == np.unicode_:
            return unicode(value)
        else:
            raise TypeError("Could not convert %s to string type" % type(value))
435930
def yaml_to_param(obj, name):
	
	return from_pyvalue(u"yaml:%s" % name, unicode(yaml.dump(obj)))
727424
public static Schema fromYaml(String yaml) {
        try{
            return JsonMappers.getMapperYaml().readValue(yaml, Schema.class);
        } catch (Exception e){
            //TODO better exceptions
            throw new RuntimeException(e);
        }
    }
1192617
def _tostring(value):
        ''''''
        if value is True:
            value = 'true'
        elif value is False:
            value = 'false'
        elif value is None:
            value = ''
        return unicode(value)
516417
def to_yaml(cls, representer, node):
        """"""
        return representer.represent_scalar(cls.yaml_tag, node.value)
881111
def parse_yaml(self, y):
        '''

        '''
        self.id = y['id']
        self._config_data = []
        if 'configurationData' in y:
            for d in y.get('configurationData'):
                self._config_data.append(ConfigurationData().parse_yaml(d))
        return self
676655
def load_yaml(filename):
    
    with open(filename) as f:
        ydoc = yaml.safe_load(f.read())
    return (ydoc, serialize_tojson(ydoc))
808793
def parse_yaml(self, y):
        ''''''
        self.x = int(y['x'])
        self.y = int(y['y'])
        self.height = int(y['height'])
        self.width = int(y['width'])
        self.direction = dir.from_string(y['direction'])
        return self
630845
def _to_string(val):
    """"""
    if isinstance(val, binary_type):
        return val.decode('utf-8')
    assert isinstance(val, text_type)
    return val