Exemplo n.º 1
0
    def serialize(cls, value, *args, **kwargs):
        if value is None:
            return ''

        if SHOULD_NOT_USE_LOCALE:
            return types.UnicodeType(value)
        else:
            grouping = kwargs.get('grouping', None)
            return locale.format('%f', value, grouping=grouping)
def convert_to_long_pathname(filename):
    if sys.platform != "win32":
        return filename
    else:
        if CTYPES_AVAILABLE:
            buf = ctypes.create_unicode_buffer(260)
            GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
            rv = GetLongPathName(types.UnicodeType(filename), buf, 260)
            if rv != 0 and rv <= 260:
                return buf.value.encode(getfilesystemencoding())
        return filename
Exemplo n.º 3
0
    def serialize(cls, value, *args, **kwargs):
        if value is None:
            return ''

        value_as_string = types.UnicodeType(value)
        if SHOULD_NOT_USE_LOCALE:
            return value_as_string
        else:
            grouping = kwargs.get('grouping', None)
            has_decimal_places = value_as_string.find('.') != -1
            if not has_decimal_places:
                string_format = '%d'
            else:
                decimal_places = len(value_as_string.split('.')[1])
                string_format = '%.{}f'.format(decimal_places)
            return locale.format(string_format, value, grouping=grouping)
Exemplo n.º 4
0
    def serialize(cls, value, *args, **kwargs):
        if value is None:
            return ''

        return types.UnicodeType(value)
Exemplo n.º 5
0
    def serialize(cls, value, *args, **kwargs):
        if value is None:
            return ''

        return types.UnicodeType(value.strftime(cls.OUTPUT_FORMAT))