OILS / pylib / pylocale.py View on Github | oils.pub

31 lines, 15 significant
1#!/usr/bin/env python2
2"""
3The subset of Lib/locale.py we use, with type annotations
4
5That wraps Modules/_localemodule.c aka _locale.so
6"""
7from __future__ import print_function
8
9import _locale # type: ignore
10
11CODESET = _locale.CODESET # type: int
12LC_ALL = _locale.LC_ALL # type: int
13LC_CTYPE = _locale.LC_CTYPE # type: int
14LC_COLLATE = _locale.LC_COLLATE # type: int
15
16
17class Error(Exception):
18 pass
19
20
21def setlocale(category, locale):
22 # type: (int, str) -> str
23 try:
24 return _locale.setlocale(category, locale) # type: ignore
25 except _locale.Error:
26 raise Error()
27
28
29def nl_langinfo(item):
30 # type: (int) -> str
31 return _locale.nl_langinfo(item) # type: ignore