From 1ab9caf8c135f91af377b4fb3629e8e4bf6dd610 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 25 Mar 2024 14:26:54 +0000 Subject: [PATCH] Simplify code following review --- src/ted2zim/scraper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ted2zim/scraper.py b/src/ted2zim/scraper.py index c0d0dc1..0ee3a70 100644 --- a/src/ted2zim/scraper.py +++ b/src/ted2zim/scraper.py @@ -106,11 +106,11 @@ def sort_languages_hack(languages: set[str]) -> list[str]: For now, if eng is among the list, we assume it is the most important language. Otherwise list is kept as-is """ - if "eng" in languages: - return ["eng", *[lang for lang in languages if lang != "eng"]] - return list(languages) + return list(languages).sort( + key=lambda x: -1 if x == "eng" else 0 + ) # pyright: ignore[reportReturnType] - if len(self.languages) == 0: + if not self.languages: self.zim_languages = "eng" else: self.zim_languages = ",".join(