Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/locale.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/locale.py')
-rw-r--r--archinstall/lib/locale.py23
1 files changed, 8 insertions, 15 deletions
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]: