MCPcopy Index your code
hub / github.com/RustPython/RustPython / _getdefaultlocale

Function _getdefaultlocale

Lib/locale.py:557–584  ·  view source on GitHub ↗
(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))

Source from the content-addressed store, hash-verified

555
556
557def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
558 try:
559 # check if it's supported by the _locale module
560 import _locale
561 code, encoding = _locale._getdefaultlocale()
562 except (ImportError, AttributeError):
563 pass
564 else:
565 # make sure the code/encoding values are valid
566 if sys.platform == "win32" and code and code[:2] == "0x":
567 # map windows language identifier to language name
568 code = windows_locale.get(int(code, 0))
569 # ...add other platform-specific processing here, if
570 # necessary...
571 return code, encoding
572
573 # fall back on POSIX behaviour
574 import os
575 lookup = os.environ.get
576 for variable in envvars:
577 localename = lookup(variable,None)
578 if localename:
579 if variable == 'LANGUAGE':
580 localename = localename.split(':')[0]
581 break
582 else:
583 localename = 'C'
584 return _parse_localename(localename)
585
586
587def getlocale(category=LC_CTYPE):

Callers 1

getdefaultlocaleFunction · 0.85

Calls 4

_parse_localenameFunction · 0.85
lookupFunction · 0.70
getMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected