index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/locale.py | 23 |
diff --git a/archinstall/lib/locale.py b/archinstall/lib/locale.py index 0a36c072..ab158984 100644 --- a/archinstall/lib/locale.py +++ b/archinstall/lib/locale.py @@ -1,3 +1,5 @@ +from itertools import takewhile +from pathlib import Path from typing import Iterator, List from .exceptions import ServiceException, SysCallError @@ -11,21 +13,12 @@ def list_keyboard_languages() -> Iterator[str]: def list_locales() -> List[str]: - with open('/etc/locale.gen', 'r') as fp: - locales = [] - # before the list of locales begins there's an empty line with a '#' in front - # so we'll collect the localels from bottom up and halt when we're donw - entries = fp.readlines() - entries.reverse() - - for entry in entries: - text = entry.replace('#', '').strip() - if text == '': - break - locales.append(text) - - locales.reverse() - return locales + entries = Path('/etc/locale.gen').read_text().splitlines() + # Before the list of locales begins there's an empty line with a '#' in front + # so we'll collect the locales from bottom up and halt when we're done. + locales = list(takewhile(bool, map(lambda entry: entry.strip('\n\t #'), reversed(entries)))) + locales.reverse() + return locales def list_x11_keyboard_languages() -> Iterator[str]: |