From 7a765d88db2f963de988558f1a09168a3b1ff1a6 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Tue, 7 Nov 2023 14:14:00 +0800 Subject: [PATCH] Show warning if `--language` code can't be found in the langcodes db --- src/wiktextract/wiktwords.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wiktextract/wiktwords.py b/src/wiktextract/wiktwords.py index be24b828..10d8821a 100755 --- a/src/wiktextract/wiktwords.py +++ b/src/wiktextract/wiktwords.py @@ -14,7 +14,6 @@ import logging import os import pstats -import re import sys from pathlib import Path from typing import TextIO @@ -24,6 +23,7 @@ else: from importlib.resources import files +from mediawiki_langcodes import code_to_name from wikitextprocessor import Wtp from wikitextprocessor.dumpparser import analyze_and_overwrite_pages @@ -334,6 +334,10 @@ def main(): # Default to English and Translingual if language not specified. if not args.language: args.language = ["en", "mul"] + else: + for lang_code in args.language: + if code_to_name(lang_code) == "": + logging.warning(f"Unknown language code: {lang_code}") if args.all_languages: args.language = None