Lichen

lib/locale.py

402:10fffa3651d9
2016-12-14 Paul Boddie Made use of __len__ methods instead of the len built-in function.
     1 #!/usr/bin/env python     2      3 """     4 Locale functions.     5      6 Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>     7      8 This program is free software; you can redistribute it and/or modify it under     9 the terms of the GNU General Public License as published by the Free Software    10 Foundation; either version 3 of the License, or (at your option) any later    11 version.    12     13 This program is distributed in the hope that it will be useful, but WITHOUT    14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    15 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more    16 details.    17     18 You should have received a copy of the GNU General Public License along with    19 this program.  If not, see <http://www.gnu.org/licenses/>.    20 """    21     22 from __builtins__.types import check_int, check_string    23 from native import getlocale as _getlocale, setlocale as _setlocale    24     25 LC_CTYPE = 0    26 LC_NUMERIC = 1    27 LC_TIME = 2    28 LC_COLLATE = 3    29 LC_MONETARY = 4    30 LC_MESSAGES = 5    31 LC_ALL = 6    32     33 def setlocale(category, value):    34     35     "Set the locale for 'category' to 'value'."    36     37     check_int(category)    38     check_string(value)    39     return _setlocale(category, value)    40     41 def getlocale(category=LC_CTYPE):    42     43     "Return the locale value for 'category'."    44     45     check_int(category)    46     return _getlocale(category)    47     48 def initlocale(category=LC_CTYPE):    49     50     "Initialise the locale for 'category' from the environment."    51     52     check_int(category)    53     return _setlocale(category, "")    54     55 # vim: tabstop=4 expandtab shiftwidth=4