Example #1
0
    def nl_langinfo(space, key):
        """nl_langinfo(key) -> string
        Return the value for the locale information associated with key."""

        try:
            return space.wrap(rlocale.nl_langinfo(key))
        except ValueError:
            raise OperationError(space.w_ValueError,
                                 space.wrap("unsupported langinfo constant"))
Example #2
0
    def nl_langinfo(space, key):
        """nl_langinfo(key) -> string
        Return the value for the locale information associated with key."""

        try:
            return space.wrap(rlocale.nl_langinfo(key))
        except ValueError:
            raise OperationError(space.w_ValueError,
                                 space.wrap("unsupported langinfo constant"))
Example #3
0
def _getfilesystemencoding(space):
    if (space.config.translation.type_system == 'ootype'):
        # XXX: fix this for ootype
        return base_encoding
    #
    encoding = base_encoding
    if rlocale.HAVE_LANGINFO and rlocale.CODESET:
        try:
            oldlocale = rlocale.setlocale(rlocale.LC_CTYPE, None)
            rlocale.setlocale(rlocale.LC_CTYPE, "")
            try:
                loc_codeset = rlocale.nl_langinfo(rlocale.CODESET)
                if loc_codeset:
                    codecmod = space.getbuiltinmodule('_codecs')
                    w_res = space.call_method(codecmod, 'lookup',
                                              space.wrap(loc_codeset))
                    if space.is_true(w_res):
                        encoding = loc_codeset
            finally:
                rlocale.setlocale(rlocale.LC_CTYPE, oldlocale)
        except rlocale.LocaleError:
            pass
    return encoding
Example #4
0
def _getfilesystemencoding(space):
    if (space.config.translation.type_system == 'ootype'):
        # XXX: fix this for ootype
        return base_encoding
    #
    encoding = base_encoding
    if rlocale.HAVE_LANGINFO and rlocale.CODESET:
        try:
            oldlocale = rlocale.setlocale(rlocale.LC_CTYPE, None)
            rlocale.setlocale(rlocale.LC_CTYPE, "")
            try:
                loc_codeset = rlocale.nl_langinfo(rlocale.CODESET)
                if loc_codeset:
                    codecmod = space.getbuiltinmodule('_codecs')
                    w_res = space.call_method(codecmod, 'lookup',
                                              space.wrap(loc_codeset))
                    if space.is_true(w_res):
                        encoding = loc_codeset
            finally:
                rlocale.setlocale(rlocale.LC_CTYPE, oldlocale)
        except rlocale.LocaleError:
            pass
    return encoding