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

Function find

Lib/gettext.py:488–521  ·  view source on GitHub ↗
(domain, localedir=None, languages=None, all=False)

Source from the content-addressed store, hash-verified

486
487# Locate a .mo file using the gettext strategy
488def find(domain, localedir=None, languages=None, all=False):
489 # Get some reasonable defaults for arguments that were not supplied
490 if localedir is None:
491 localedir = _default_localedir
492 if languages is None:
493 languages = []
494 for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
495 val = os.environ.get(envar)
496 if val:
497 languages = val.split(':')
498 break
499 if 'C' not in languages:
500 languages.append('C')
501 # now normalize and expand the languages
502 nelangs = []
503 for lang in languages:
504 for nelang in _expand_lang(lang):
505 if nelang not in nelangs:
506 nelangs.append(nelang)
507 # select a language
508 if all:
509 result = []
510 else:
511 result = None
512 for lang in nelangs:
513 if lang == 'C':
514 break
515 mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain)
516 if os.path.exists(mofile):
517 if all:
518 result.append(mofile)
519 else:
520 return mofile
521 return result
522
523
524# a mapping between absolute .mo file path and Translation object

Callers 5

translationFunction · 0.70
_set_alpn_protocolsMethod · 0.50
py_findMethod · 0.50
_containsMethod · 0.50
findMethod · 0.50

Calls 6

_expand_langFunction · 0.85
getMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected