From 506242740f7b1e85a9c0b29fa4355306e42b8fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 2 Nov 2015 14:56:00 +0100 Subject: [PATCH] fix capitalization issues --- gallery_dl/iso639_1.py | 3 ++- test/test_iso639_1.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gallery_dl/iso639_1.py b/gallery_dl/iso639_1.py index 2e639e9f..5e690dd3 100644 --- a/gallery_dl/iso639_1.py +++ b/gallery_dl/iso639_1.py @@ -10,10 +10,11 @@ def code_to_language(code, default="English"): """Map an ISO 639-1 language code to its actual name""" - return codes.get(code, default) + return codes.get(code.lower(), default) def language_to_code(lang, default="en"): """Map a language name to its ISO 639-1 code""" + lang = lang.capitalize() for code, language in codes.items(): if language == lang: return code diff --git a/test/test_iso639_1.py b/test/test_iso639_1.py index 1e705ce0..50c7c71d 100644 --- a/test/test_iso639_1.py +++ b/test/test_iso639_1.py @@ -14,10 +14,12 @@ class TestISO639_1(unittest.TestCase): def test_code_to_language(self): self.assertEqual(iso639_1.code_to_language("en"), "English") + self.assertEqual(iso639_1.code_to_language("FR"), "French") self.assertEqual(iso639_1.code_to_language("xx"), "English") self.assertEqual(iso639_1.code_to_language("xx", default=None), None) def test_language_to_code(self): self.assertEqual(iso639_1.language_to_code("English"), "en") + self.assertEqual(iso639_1.language_to_code("fRENch"), "fr") self.assertEqual(iso639_1.language_to_code("Nothing"), "en") self.assertEqual(iso639_1.language_to_code("Nothing", default=None), None)