Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion babel/localedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def resolve_locale_filename(name: os.PathLike[str] | str) -> str:
return os.path.join(_dirname, f"{name}.dat")


@lru_cache(maxsize=None)
def exists(name: str) -> bool:
"""Check whether locale data is available for the given locale.

Expand All @@ -72,7 +73,7 @@ def exists(name: str) -> bool:
if name in _cache:
return True
file_found = os.path.exists(resolve_locale_filename(name))
return True if file_found else bool(normalize_locale(name))
return file_found or bool(normalize_locale(name))


@lru_cache(maxsize=None)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_localedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def test_locale_argument_acceptance():
assert normalized_locale is None
assert not localedata.exists(None)

# Testing list input.
# Testing tuple input.
normalized_locale = localedata.normalize_locale(['en_us', None])
assert normalized_locale is None
assert not localedata.exists(['en_us', None])
assert not localedata.exists(('en_us', None))


def test_locale_identifiers_cache(monkeypatch):
Expand Down
Loading