MCPcopy Index your code
hub / github.com/python/cpython / _build_localename

Function _build_localename

Lib/locale.py:510–536  ·  view source on GitHub ↗

Builds a locale code from the given tuple (language code, encoding). No aliasing or normalizing takes place.

(localetuple)

Source from the content-addressed store, hash-verified

508 raise ValueError('unknown locale: %s' % localename)
509
510def _build_localename(localetuple):
511
512 """ Builds a locale code from the given tuple (language code,
513 encoding).
514
515 No aliasing or normalizing takes place.
516
517 """
518 try:
519 language, encoding = localetuple
520
521 if language is None:
522 language = 'C'
523 if encoding is None:
524 return language
525 else:
526 if '@' in language:
527 language, modifier = language.split('@', 1)
528 else:
529 modifier = ''
530 localename = language + '.' + encoding
531 if modifier:
532 localename += '@' + modifier
533 return localename
534 except (TypeError, ValueError):
535 raise TypeError('Locale must be None, a string, or an iterable of '
536 'two strings -- language code, encoding.') from None
537
538def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
539

Callers 1

setlocaleFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…