From weird splits into regex
This commit is contained in:
parent
63d565b89c
commit
409ac4157a
|
@ -119,12 +119,24 @@ class ConfigureController(SubiquityController):
|
|||
return True
|
||||
|
||||
async def _install_check_lang_support_packages(self, lang, env) -> bool:
|
||||
""" Installs any packages recommended by
|
||||
check-language-support command. """
|
||||
""" Installs packages recommended by check-language-support command.
|
||||
lang is expected to be one single language/locale. """
|
||||
|
||||
clsCommand = "check-language-support"
|
||||
# lang may have more than 5 chars and be separated by dot or space.
|
||||
clsLang = lang.split('@')[0].split('.')[0].split(' ')[0]
|
||||
# lang code may be separated by @, dot or spaces.
|
||||
# clsLang = lang.split('@')[0].split('.')[0].split(' ')[0]
|
||||
pattern = re.compile(r'([^.@\s]+)', re.IGNORECASE)
|
||||
matches = pattern.match(lang)
|
||||
if matches is None:
|
||||
log.error("Failed to match expected language format: %s", lang)
|
||||
return False
|
||||
|
||||
langCodes = matches.groups()
|
||||
if len(langCodes) != 1:
|
||||
log.error("Only one match was expected for: %s", lang)
|
||||
return False
|
||||
|
||||
clsLang = langCodes[0]
|
||||
|
||||
# Running that command doesn't require root.
|
||||
cp = await arun_command([clsCommand, "-l", clsLang], env=env)
|
||||
|
|
Loading…
Reference in New Issue