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