comparison babel/util.py @ 39:008de2f257a6 trunk

Move function for determining the system default locale to `babel.core`, and make it available as a class method on `Locale`.
author cmlenz
date Wed, 06 Jun 2007 11:02:24 +0000
parents 4a2b3ba40b7c
children a524b547ea7e
comparison
equal deleted inserted replaced
38:7ae4722af473 39:008de2f257a6
15 15
16 from datetime import timedelta, tzinfo 16 from datetime import timedelta, tzinfo
17 import os 17 import os
18 import re 18 import re
19 19
20 __all__ = ['default_locale', 'extended_glob', 'relpath', 'LazyProxy', 'UTC'] 20 __all__ = ['extended_glob', 'relpath', 'LazyProxy', 'UTC']
21 __docformat__ = 'restructuredtext en' 21 __docformat__ = 'restructuredtext en'
22
23 def default_locale(kind=None):
24 """Returns the default locale for a given category, based on environment
25 variables.
26
27 :param kind: one of the ``LC_XXX`` environment variable names
28 :return: the value of the variable, or any of the fallbacks (``LC_ALL`` and
29 ``LANG``)
30 :rtype: `str`
31 """
32 for name in filter(None, (kind, 'LC_ALL', 'LANG')):
33 locale = os.getenv(name)
34 if locale is not None:
35 return locale
36 22
37 def extended_glob(pattern, dirname=''): 23 def extended_glob(pattern, dirname=''):
38 """Extended pathname pattern expansion. 24 """Extended pathname pattern expansion.
39 25
40 This function is similar to what is provided by the ``glob`` module in the 26 This function is similar to what is provided by the ``glob`` module in the
Copyright (C) 2012-2017 Edgewall Software