Builds a locale code from the given tuple (language code, encoding). No aliasing or normalizing takes place.
(localetuple)
| 508 | raise ValueError('unknown locale: %s' % localename) |
| 509 | |
| 510 | def _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 | |
| 538 | def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')): |
| 539 |