Return a unicode object with the Gremlin representation of this expression.
518301
def to_gremlin(self):
        """"""
        self.validate()

        mark_name, field_name = self.location.get_location_name()
        validate_safe_string(mark_name)
        validate_safe_string(field_name)

        if '@' in field_name:
            template = u'm.{mark_name}[\'{field_name}\']'
        else:
            template = u'm.{mark_name}.{field_name}'

        format_value = None
        stripped_field_type = strip_non_null_from_type(self.field_type)
        if GraphQLDate.is_same_type(stripped_field_type):
            template += '.format("{format}")'
            format_value = STANDARD_DATE_FORMAT
        elif GraphQLDateTime.is_same_type(stripped_field_type):
            template += '.format("{format}")'
            format_value = STANDARD_DATETIME_FORMAT

        return template.format(mark_name=mark_name, field_name=field_name,
                               format=format_value)
1361253
def ensure_unicode(text):
    """
    if isinstance(text, str):
        try:
            return text.decode(pyreadline_codepage, u"replace")
        except (LookupError, TypeError):
            return text.decode(u"ascii", u"replace")
    return text
679048
def unicodestr(s, encoding='utf-8', fallback='iso-8859-1'):
    """"""

    if isinstance(s, unicode):
        return s

    try:
        return s.decode(encoding)
    except UnicodeError:
        return s.decode(fallback)
266440
def render_unicode(self, *args, **data):
        """"""

        return runtime._render(self,
                                self.callable_,
                                args,
                                data,
                                as_unicode=True)
1027527
def get_unicode(self):
        
        s = mutf8.decode(self.data)
        if len(s) != self.utf16_size:
            raise ValueError("UTF16 Length does not match!")

        # Return a UTF16 String
        return s
215031
def safe_unicode(value):
    
    if sys.version_info < (3,0):
        if isinstance(value, str):
            return value.decode('utf-8')
        else:
            return unicode(value)
    else:
        return str(value)
451964
def to_str(obj):
    
    if isinstance(obj, str):
        return obj
    if isinstance(obj, unicode):
        return obj.encode('utf-8')
    return str(obj)
965373
def value_to_string(self, obj):
        """"""
        try:
            return force_unicode(self.__get__(obj))
        except TypeError:
            return str(self.__get__(obj))
926133
def make_unicode(string):
    
    if sys.version < '3' and isinstance(string, str):
        return unicode(string.decode('utf-8'))

    return string
486475
def convert(self, string, preprocess = None):
        
        string = unicode(preprocess(string) if preprocess else string, encoding="utf-8")
        if self.regex:
            return self.regex.sub(lambda x: self.substitutes[x.group()], string).encode('utf-8')
        else:
            return string
278974
def convert_unicode(value):
    
    if isinstance(value, dict):
        return {convert_unicode(key): convert_unicode(value)
                for key, value in value.iteritems()}
    elif isinstance(value, list):
        return [convert_unicode(item) for item in value]
    elif isinstance(value, unicode):
        return value.encode('utf-8')
    else:
        return value
65745
def _native_to_unicode(s):
  """"""
  if six.PY2:
    return s if isinstance(s, unicode) else s.decode("utf-8")
  else:
    return s
900972
def to_gremlin(self):
        """"""
        self.validate()
        mark_name, _ = self.location.get_location_name()
        return u'as({})'.format(safe_quoted_string(mark_name))
594507
def u2s(self,u):
		""""""

		try:
			return u.encode('utf-8',errors='ignore')
		except (UnicodeDecodeError,AttributeError) as e:
			try:
				return str(u)
			except UnicodeEncodeError:
				return unicode(u).encode('utf-8',errors='ignore')
193456
def make_unicode(s, encoding='utf-8', encoding_errors='strict'):
    
    if not isinstance(s, unicode):
        if not isinstance(s, basestring):
            return unicode(str(s), encoding, encoding_errors)
        return unicode(s, encoding, encoding_errors)
    return s
699413
def stream_decode_response_unicode(iterator, r):
    """"""
    encoding = get_encoding_from_headers(r.headers)
    if encoding is None:
        for item in iterator:
            yield item
        return

    decoder = codecs.getincrementaldecoder(encoding)(errors='replace')
    for chunk in iterator:
        rv = decoder.decode(chunk)
        if rv:
            yield rv
    rv = decoder.decode('', final=True)
    if rv:
        yield rv
1015682
def safe_unicode(string):
    """"""
    if not PY3:
        uni = string.replace(u'\u2019', "'")
        return uni.encode('utf-8')
        
    return string