Convert any value to string.
965003
def stringify_value(value):
    
    if value is None:
        return u''
    isoformat = getattr(value, 'isoformat', None)
    if isoformat is not None:
        value = isoformat()
    return type(u'')(value)
952523
def _convert_string_to_native(value):
    """"""
    result = None

    try:
        result = ast.literal_eval(str(value))
    except (SyntaxError, ValueError):
        # Likely a string
        result = value.split(',')
    return result
2292
def _to_string(x):
    
    if x == ffi.NULL:
        x = 'NULL'
    else:
        x = ffi.string(x)
        if isinstance(x, byte_type):
            x = x.decode('utf-8')

    return x
1012574
def to_string(self, value):
        """"""
        if isinstance(value, six.binary_type):
            value = value.decode('utf-8')
        return self.to_json(value)
1116414
def encode(self, value):
        """"""
        if isinstance(value, bytes):
            return value
        elif isinstance(value, int):
            value = b(str(value))
        elif isinstance(value, float):
            value = b(repr(value))
        elif not isinstance(value, str):
            value = str(value)
        if isinstance(value, str):
            value = value.encode()
        return value
440265
def __convert_string(node):
    """"""
    converted = __convert_node(node, default_flags=vsflags(VSFlags.UserValue))

    return __check_for_flag(converted)
884800
private static function convertToString($value): string
    {
        // float value (INF and NAN are float type)
        if (is_float($value)) {
            if (is_infinite($value)) {
                $value = 'INF';
            } elseif (is_nan($value)) {
                $value = 'NAN';
            } else {
                $value = (string) $value;
                if (self::XML_PRESERVE_ZERO_FRACTION && strpos($value, '.') === false) {
                    $value .= '.0';
                }
            }
        }

        // bool value
        if (is_bool($value)) {
            $value = ($value === true) ? 'true' : 'false';
        }

        // class value
        if (is_object($value)) {
            $value = json_encode($value);
        }

        // int or string value.
        return (string) $value;
    }
86818
def to_simple(self, value, **options):  # nolint
        "  "

        # (string, unicode)
        if isinstance(value, basestring):
            return smart_unicode(value)

        # (int, long, float, real, complex, decimal)
        if isinstance(value, Number):
            return float(str(value)) if isinstance(value, Decimal) else value

        # (datetime, data, time)
        if isinstance(value, (datetime, date, time)):
            return self.to_simple_datetime(value)

        # (dict, ordereddict, mutable mapping)
        if isinstance(value, collections.MutableMapping):
            return dict(
                (k, self.to_simple(v, **options)) for k, v in value.items())

        # (tuple, list, set, iterators)
        if isinstance(value, collections.Iterable):
            return [self.to_simple(o, **options) for o in value]

        # (None, True, False)
        if value is None or value is True or value is False:
            return value

        if hasattr(value, 'to_simple') and not inspect.isclass(value):
            return self.to_simple(value.to_simple(self), **options)

        if isinstance(value, Model):
            return self.to_simple_model(value, **options)

        return str(value)
1230087
def tostring(self, root=None, doctype=None, pretty_print=True):
        """"""
        if root is None:
            root = self.root
        return etree.tounicode(
            root, doctype=doctype or self.info.doctype, pretty_print=pretty_print
        )
680970
def to_string_with_default(value, default_value):
        
        result = StringConverter.to_nullable_string(value)
        return result if result != None else default_value
400418
private function as_string( $value ) {

		if ( is_object( $value ) && method_exists( $value, '__toString' ) ) {
			$value = (string) $value;
		}

		if ( is_string( $value ) ) {
			return $value;
		} elseif ( is_null( $value ) ) {
			return 'NULL';
		} elseif ( is_bool( $value ) ) {
			return $value ? '(boolean) TRUE' : '(boolean) FALSE';
		}

		if ( is_object( $value ) ) {
			$value = get_class( $value );
			$type  = '(object) ';
		} elseif ( is_array( $value ) ) {
			$type  = '';
			$value = var_export( $value, TRUE );
		}

		isset( $type ) or $type = '(' . gettype( $value ) . ') ';

		return $type . (string) $value;
	}
773921
def value_to_string(self, obj):
        
        statefield = self.to_python(self.value_from_object(obj))
        return statefield.state.name
1134084
def get_as_string(self, key):
        
        value = self.get(key)
        return StringConverter.to_string(value)
426971
String convertToString(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof String) {
            return (String) value;
        } else if (value instanceof List) {
            List<?> list = ((List<?>) value);
            if (list.size() == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (list.size() == 1) {
                String strValue = String.valueOf(list.get(0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                Iterator<?> iterator = list.iterator();
                while (iterator.hasNext()) {
                    String strValue = String.valueOf(iterator.next());
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (iterator.hasNext()) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value instanceof String[]) {
            String[] array = (String[]) value;
            if (array.length == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (array.length == 1) {
                return escapeValue(array[0]);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < array.length; i++) {
                    String strValue = escapeValue(array[i]);
                    builder.append(strValue);
                    if (i + 1 < array.length) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value.getClass().isArray()) {
            int size = Array.getLength(value);
            if (size == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (size == 1) {
                String strValue = String.valueOf(Array.get(value, 0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < size; i++) {
                    String strValue = String.valueOf(Array.get(value, i));
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (i + 1 < size) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else {
            return value.toString();
        }
    }
1081898
def string(v):
    """"""
    if nodesetp(v):
        if not v:
            return u''
        return string_value(v[0])
    elif numberp(v):
        if v == float('inf'):
            return u'Infinity'
        elif v == float('-inf'):
            return u'-Infinity'
        elif str(v) == 'nan':
            return u'NaN'
        elif int(v) == v and v <= 0xffffffff:
            v = int(v)
        return unicode(v)
    elif booleanp(v):
        return u'true' if v else u'false'
    return v
635279
def _asString(self, value):
        """"""
        if sys.version_info[0] == 3:
            if isinstance(value, str):
                return value
            elif isinstance(value, bytes):
                return value.decode('utf-8')
        elif sys.version_info[0] == 2:
            return value.encode('ascii')
414390
def stringify(self, value):
        
        # SuperModel -> UID
        if ISuperModel.providedBy(value):
            return str(value)
        # DateTime -> ISO8601 format
        elif isinstance(value, (DateTime)):
            return value.ISO8601()
        # Image/Files -> filename
        elif safe_hasattr(value, "filename"):
            return value.filename
        # Dict -> convert_value_to_string
        elif isinstance(value, dict):
            return {k: self.stringify(v) for k, v in value.iteritems()}
        # List -> convert_value_to_string
        if isinstance(value, (list, tuple, LazyMap)):
            return map(self.stringify, value)
        # Callables
        elif safe_callable(value):
            return self.stringify(value())
        elif isinstance(value, unicode):
            value = value.encode("utf8")
        try:
            return str(value)
        except (AttributeError, TypeError, ValueError):
            logger.warn("Could not convert {} to string".format(repr(value)))
            return None