Python _locale.setlocale() Examples
The following are 22
code examples of _locale.setlocale().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_locale
, or try the search function
.
Example #1
Source File: re.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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
Example #2
Source File: test__locale.py From ironpython2 with Apache License 2.0 | 6 votes |
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")
Example #3
Source File: test__locale.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: re.py From syntheticmass with Apache License 2.0 | 6 votes |
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
Example #5
Source File: re.py From oss-ftp with MIT License | 6 votes |
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
Example #6
Source File: re.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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
Example #7
Source File: re.py From PhonePi_SampleServer with MIT License | 6 votes |
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
Example #8
Source File: re.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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
Example #9
Source File: re.py From telegram-robot-rss with Mozilla Public License 2.0 | 6 votes |
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
Example #10
Source File: re.py From ironpython2 with Apache License 2.0 | 6 votes |
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
Example #11
Source File: re.py From ImageFusion with MIT License | 6 votes |
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
Example #12
Source File: test__locale.py From ironpython3 with Apache License 2.0 | 6 votes |
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")
Example #13
Source File: test__locale.py From ironpython3 with Apache License 2.0 | 6 votes |
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)
Example #14
Source File: re.py From ironpython3 with Apache License 2.0 | 5 votes |
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
Example #15
Source File: re.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #16
Source File: test__locale.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_bad_category(self): self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', 'en_US.UTF8') self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', None)
Example #17
Source File: test__locale.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_strcoll(self): _locale.setlocale(_locale.LC_COLLATE,"English") self.validcollate() _locale.setlocale(_locale.LC_COLLATE,"French") self.validcollate()
Example #18
Source File: re.py From scylla with Apache License 2.0 | 5 votes |
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
Example #19
Source File: re.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #20
Source File: re.py From kobo-predict with BSD 2-Clause "Simplified" License | 5 votes |
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
Example #21
Source File: test__locale.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_bad_category(self): self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', 'en_US.UTF8') self.assertRaises(TypeError, _locale.setlocale, 'LC_NUMERIC', None)
Example #22
Source File: test__locale.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_strcoll(self): _locale.setlocale(_locale.LC_COLLATE,"English") self.validcollate() _locale.setlocale(_locale.LC_COLLATE,"French") self.validcollate()