当前位置: 首页>>代码示例>>Python>>正文


Python _locale.setlocale方法代码示例

本文整理汇总了Python中_locale.setlocale方法的典型用法代码示例。如果您正苦于以下问题:Python _locale.setlocale方法的具体用法?Python _locale.setlocale怎么用?Python _locale.setlocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_locale的用法示例。


在下文中一共展示了_locale.setlocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _compile

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def _compile(*key):
    # internal: compile pattern
    pattern, flags = key
    bypass_cache = flags & DEBUG
    if not bypass_cache:
        cachekey = (type(key[0]),) + key
        try:
            p, loc = _cache[cachekey]
            if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE):
                return p
        except KeyError:
            pass
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError('Cannot process flags argument with a compiled pattern')
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError, "first argument must be string or compiled pattern"
    try:
        p = sre_compile.compile(pattern, flags)
    except error, v:
        raise error, v # invalid expression 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:re.py

示例2: test_setlocale

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def test_setlocale(self):
        c_list = [ _locale.LC_ALL,
                _locale.LC_COLLATE,
                _locale.LC_CTYPE,
                _locale.LC_MONETARY,
                _locale.LC_NUMERIC,
                _locale.LC_TIME,
                ]
        
        for c in c_list:
            resultLocale = None
            _locale.setlocale(c,"English")
            resultLocale = _locale.setlocale(c)
            self.assertEqual(resultLocale,"English_United States.1252")
                
                        
        for c in c_list:
            resultLocale = None
            _locale.setlocale(c,"French")
            resultLocale = _locale.setlocale(c)
            self.assertEqual(resultLocale,"French_France.1252") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test__locale.py

示例3: test_setlocale_negative

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def test_setlocale_negative(self):
        #the locale is empty string
        c= _locale.LC_ALL
        locale =''
        _locale.setlocale(c,locale)
        
        #the locale is None
        locale = _locale.setlocale(c)
        resultLocale =_locale.setlocale(c)
        self.assertEqual(locale,resultLocale)
        
        #set Numeric as a unknown locale,should thorw a _locale.Error
        locale ="11-22"
        self.assertRaises(_locale.Error,_locale.setlocale,c,locale)
        locale ="@^#^&%"
        self.assertRaises(_locale.Error,_locale.setlocale,c,locale)
        locale ="xxxxxx"
        self.assertRaises(_locale.Error,_locale.setlocale,c,locale) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test__locale.py

示例4: test_strcoll

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def test_strcoll(self):
        _locale.setlocale(_locale.LC_COLLATE,"English")
        self.validcollate()
        
        _locale.setlocale(_locale.LC_COLLATE,"French")
        self.validcollate() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test__locale.py

示例5: test_bad_category

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def test_bad_category(self):
        self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', 'en_US.UTF8')
        self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test__locale.py

示例6: _compile

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def _compile(pattern, flags):
    # internal: compile pattern
    try:
        p, loc = _cache[type(pattern), pattern, flags]
        if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE):
            return p
    except KeyError:
        pass
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError(
                "cannot process flags argument with a compiled pattern")
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError("first argument must be string or compiled pattern")
    p = sre_compile.compile(pattern, flags)
    if not (flags & DEBUG):
        if len(_cache) >= _MAXCACHE:
            _cache.clear()
        if p.flags & LOCALE:
            if not _locale:
                return p
            loc = _locale.setlocale(_locale.LC_CTYPE)
        else:
            loc = None
        _cache[type(pattern), pattern, flags] = p, loc
    return p 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:29,代码来源:re.py

示例7: _compile

# 需要导入模块: import _locale [as 别名]
# 或者: from _locale import setlocale [as 别名]
def _compile(pattern, flags):
    # internal: compile pattern
    bypass_cache = flags & DEBUG
    if not bypass_cache:
        try:
            p, loc = _cache[type(pattern), pattern, flags]
            if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE):
                return p
        except KeyError:
            pass
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError(
                "Cannot process flags argument with a compiled pattern")
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError("first argument must be string or compiled pattern")
    p = sre_compile.compile(pattern, flags)
    if not bypass_cache:
        if len(_cache) >= _MAXCACHE:
            _cache.clear()
        if p.flags & LOCALE:
            if not _locale:
                return p
            loc = _locale.setlocale(_locale.LC_CTYPE)
        else:
            loc = None
        _cache[type(pattern), pattern, flags] = p, loc
    return p 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:31,代码来源:re.py


注:本文中的_locale.setlocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。