Simon Hanna has proposed merging lp:~thelinuxguy/openlp/fix-regex into lp:openlp.
Requested reviews: OpenLP Core (openlp-core) For more details, see: https://code.launchpad.net/~thelinuxguy/openlp/fix-regex/+merge/353793 Fix the following warning which was displayed when running OpenLP in the cli /home/sim/dev/openlp/trunk/openlp/core/common/i18n.py:274: FutureWarning: Possible nested set at position 1 if re.match(r'[[].*[]]', language): -- Your team OpenLP Core is requested to review the proposed merge of lp:~thelinuxguy/openlp/fix-regex into lp:openlp.
=== modified file 'openlp/core/common/i18n.py' --- openlp/core/common/i18n.py 2018-04-12 19:15:56 +0000 +++ openlp/core/common/i18n.py 2018-08-27 14:18:33 +0000 @@ -271,9 +271,10 @@ language = Settings().value('core/language') language = str(language) log.info("Language file: '{language}' Loaded from conf file".format(language=language)) - if re.match(r'[[].*[]]', language): + m = re.match(r'\[(.*)\]', language) + if m: LanguageManager.auto_language = True - language = re.sub(r'[\[\]]', '', language) + language = m.group(1) return language @staticmethod === modified file 'tests/functional/openlp_core/common/test_i18n.py' --- tests/functional/openlp_core/common/test_i18n.py 2017-12-29 09:15:48 +0000 +++ tests/functional/openlp_core/common/test_i18n.py 2018-08-27 14:18:33 +0000 @@ -27,7 +27,8 @@ from openlp.core.common import is_macosx from openlp.core.common.i18n import LANGUAGES, Language, UiStrings, get_language, get_locale_key, get_natural_key, \ - translate + translate, LanguageManager +from openlp.core.common.settings import Settings def test_languages_type(): @@ -158,6 +159,14 @@ assert first_instance is second_instance, 'Two UiStrings objects should be the same instance' +def test_get_language_from_settings(): + assert LanguageManager.get_language() == 'en' + +def test_get_language_from_settings_returns_unchanged_if_unknown_format(): + Settings().setValue('core/language', '(foobar)') + assert LanguageManager.get_language() == '(foobar)' + + def test_translate(): """ Test the translate() function
_______________________________________________ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp