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

        template = (
            u'transform{{'
            u'it, m -> new com.orientechnologies.orient.core.record.impl.ODocument([ {} ])'
            u'}}')

        field_representations = (
            u'{name}: {expr}'.format(name=key, expr=self.fields[key].to_gremlin())
            for key in sorted(self.fields.keys())  # Sort the keys for deterministic output order.
        )
        return template.format(u', '.join(field_representations))
652960
def unicoder(p):
    
    if isinstance(p, unicode):
        return p
    if isinstance(p, str):
        return decoder(p)
    else:
        return unicode(decoder(p))
885687
def _unicode(self):
        ''''''

        return u'\n'.join ([ u''.join(c) for c in self.w ])
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')
451964
def to_str(obj):
    
    if isinstance(obj, str):
        return obj
    if isinstance(obj, unicode):
        return obj.encode('utf-8')
    return str(obj)
213901
def unicode_obj(obj):
    
    if isinstance(obj, dict):
        return unicode_dict(obj)
    elif isinstance(obj, (list, tuple)):
        return unicode_list(obj)
    elif isinstance(obj, six.string_types):
        return unicode_string(obj)
    elif isinstance(obj, (int, float)):
        return obj
    elif obj is None:
        return obj
    else:
        try:
            return text(obj)
        except:
            return text(repr(obj))
1134817
def _unicode_handler(obj):
    
    try:
        result = obj.isoformat()
    except AttributeError:
        raise TypeError("Unserializable object {} of type {}".format(obj,
                                                                     type(obj)))

    return result
220360
def get_unicode_property(value, prop=None, is_bytes=False):
    """"""

    if prop is not None:
        prop = unidata.unicode_alias['_'].get(prop, prop)
        try:
            if prop == 'generalcategory':
                return get_gc_property(value, is_bytes)
            elif prop == 'script':
                return get_script_property(value, is_bytes)
            elif prop == 'scriptextensions':
                return get_script_extension_property(value, is_bytes)
            elif prop == 'block':
                return get_block_property(value, is_bytes)
            elif prop == 'binary':
                return get_binary_property(value, is_bytes)
            elif prop == 'bidiclass':
                return get_bidi_property(value, is_bytes)
            elif prop == 'bidipairedbrackettype':
                return get_bidi_paired_bracket_type_property(value, is_bytes)
            elif prop == 'age':
                return get_age_property(value, is_bytes)
            elif prop == 'eastasianwidth':
                return get_east_asian_width_property(value, is_bytes)
            elif PY35 and prop == 'indicpositionalcategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif not PY35 and prop == 'indicmatracategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif prop == 'indicsyllabiccategory':
                return get_indic_syllabic_category_property(value, is_bytes)
            elif prop == 'hangulsyllabletype':
                return get_hangul_syllable_type_property(value, is_bytes)
            elif prop == 'decompositiontype':
                return get_decomposition_type_property(value, is_bytes)
            elif prop == 'canonicalcombiningclass':
                return get_canonical_combining_class_property(value, is_bytes)
            elif prop == 'numerictype':
                return get_numeric_type_property(value, is_bytes)
            elif prop == 'numericvalue':
                return get_numeric_value_property(value, is_bytes)
            elif prop == 'joiningtype':
                return get_joining_type_property(value, is_bytes)
            elif prop == 'joininggroup':
                return get_joining_group_property(value, is_bytes)
            elif prop == 'graphemeclusterbreak':
                return get_grapheme_cluster_break_property(value, is_bytes)
            elif prop == 'linebreak':
                return get_line_break_property(value, is_bytes)
            elif prop == 'sentencebreak':
                return get_sentence_break_property(value, is_bytes)
            elif prop == 'wordbreak':
                return get_word_break_property(value, is_bytes)
            elif prop == 'nfcquickcheck':
                return get_nfc_quick_check_property(value, is_bytes)
            elif prop == 'nfdquickcheck':
                return get_nfd_quick_check_property(value, is_bytes)
            elif prop == 'nfkcquickcheck':
                return get_nfkc_quick_check_property(value, is_bytes)
            elif prop == 'nfkdquickcheck':
                return get_nfkd_quick_check_property(value, is_bytes)
            elif PY37 and prop == 'verticalorientation':
                return get_vertical_orientation_property(value, is_bytes)
            else:
                raise ValueError('Invalid Unicode property!')
        except Exception:
            raise ValueError('Invalid Unicode property!')

    try:
        return get_gc_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_script_extension_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_block_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_binary_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_is_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_in_property(value, is_bytes)
    except Exception:
        pass

    raise ValueError('Invalid Unicode property!')
87369
def unicode_convert(obj):
    
    try:
        if isinstance(obj, dict):
            return {unicode_convert(key): unicode_convert(value) for key, value in obj.items()}
        elif isinstance(obj, list):
            return [unicode_convert(element) for element in obj]
        elif isinstance(obj, str):
            return obj 
        elif isinstance(obj, six.text_type):
            return obj.encode('utf-8')
        elif isinstance(obj, six.integer_types):
            return obj
        else:
            return obj
    except:
        return obj
641005
def to_unicode(text):
    """"""
    if isinstance(text, unicode):
        return text
    if isinstance(text, six.string_types):
        return decode_to_unicode(text)
    return unicode(text)
989456
def unicode_compatible(cls):
    
    if not is_py3:
        cls.__unicode__ = cls.__str__
        cls.__str__ = lambda self: self.__unicode__().encode('utf-8')
    return cls
4213
def to_unicode(data, encoding='UTF-8'):
    """"""
    if isinstance(data, unicode_type):
        return data

    if isinstance(data, bytes):
        return unicode_type(data, encoding=encoding)

    if hasattr(data, '__iter__'):
        try:
            dict(data)
        except TypeError:
            pass
        except ValueError:
            # Assume it's a one dimensional data structure
            return (to_unicode(i, encoding) for i in data)
        else:
            # We support 2.6 which lacks dict comprehensions
            if hasattr(data, 'items'):
                data = data.items()
            return dict(((to_unicode(k, encoding), to_unicode(v, encoding)) for k, v in data))

    return data
952823
def s(obj):
    """"""
    if isinstance(obj, bytes):
        return obj.replace(b'\n', os.linesep.encode())
    else:
        return obj.replace('\n', os.linesep)
558310
def code_to_unicode(code):
    """
    def utf32chr(n):
        """utf32char for narrow build python"""
        return eval("u\'\\U%08X\'" % n)
    def lazy_unichr(n):
        try:
            return unichr(n)
        except ValueError:
            warnings.warn("Your python it built as narrow python. Make with "
                "'--enable-unicode=ucs4' configure option to build wide python")
            return utf32chr(n)
    if code and isinstance(code, basestring):
        clean_code = code.replace('>', '')
        if clean_code:
            return u''.join([lazy_unichr(int(code_char, 16)) for code_char in clean_code.split('+') if code_char])
    return None
146817
def obj2unicode(obj):
    
    if isinstance(obj, unicode_type):
        return obj
    elif isinstance(obj, bytes_type):
        try:
            return unicode_type(obj, 'utf-8')
        except UnicodeDecodeError as strerror:
            sys.stderr.write("UnicodeDecodeError exception for string '%s': %s\n" % (obj, strerror))
            return unicode_type(obj, 'utf-8', 'replace')
    else:
        return unicode_type(obj)
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
222936
def _unicode(value):
    
    if isinstance(value, _TO_UNICODE_TYPES):
        return value
    if not isinstance(value, bytes_type):
        raise TypeError(
            "Expected bytes, unicode, or None; got %r" % type(value)
        )
    return value.decode("utf-8")