From 4032d6950f3b2e0e78d6749ad44a45d95caf9ad4 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 16 Mar 2017 07:00:06 -0400 Subject: [PATCH] remove hacking rule that enforces log translation All of the po files for log translation have been deleted from the Nova tree as of I3206d8bcbffe7ef1d84acf0fac6b423a26fccf94 which has made all of this infrastructure unused. The mailing list discussions are pretty much all coming back to the fact that no one ever really wanted this feature, and it was pushed in purely as a product requirement checklist. This removes hacking enforcement of this now unused feature, and will allow people to start deleting the i18n markup without coming afoul of hacking. Change-Id: I9c334162fe1799e7b24563fdc11256b91bbafc9f --- nova/hacking/checks.py | 23 ----------------------- nova/tests/unit/test_hacking.py | 26 -------------------------- 2 files changed, 49 deletions(-) diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index b4a477adcadc..886547c51180 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -311,28 +311,6 @@ def no_setting_conf_directly_in_tests(logical_line, filename): "forbidden. Use self.flags(option=value) instead") -def validate_log_translations(logical_line, physical_line, filename): - # Translations are not required in the test directory - # and the Xen utilities - if ("nova/tests" in filename or - "plugins/xenserver/xenapi/etc/xapi.d" in filename): - return - if pep8.noqa(physical_line): - return - msg = "N328: LOG.info messages require translations `_LI()`!" - if log_translation_info.match(logical_line): - yield (0, msg) - msg = "N329: LOG.exception messages require translations `_LE()`!" - if log_translation_exception.match(logical_line): - yield (0, msg) - msg = "N330: LOG.warning, LOG.warn messages require translations `_LW()`!" - if log_translation_LW.match(logical_line): - yield (0, msg) - msg = "N321: Log messages require translations!" - if log_translation.match(logical_line): - yield (0, msg) - - def no_mutable_default_args(logical_line): msg = "N322: Method's default argument shouldn't be mutable!" if mutable_default_args.match(logical_line): @@ -846,7 +824,6 @@ def factory(register): register(assert_raises_regexp) register(no_translate_debug_logs) register(no_setting_conf_directly_in_tests) - register(validate_log_translations) register(no_mutable_default_args) register(check_explicit_underscore_import) register(use_jsonutils) diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index aa138404fc0d..47b4ce518f0f 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -208,32 +208,6 @@ class HackingTestCase(test.NoDBTestCase): self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests( "CONF.option = 1", "nova/compute/foo.py"))), 0) - def test_log_translations(self): - logs = ['audit', 'error', 'info', 'warning', 'critical', 'warn', - 'exception'] - levels = ['_LI', '_LW', '_LE', '_LC'] - debug = "LOG.debug('OK')" - self.assertEqual( - 0, len(list(checks.validate_log_translations(debug, debug, 'f')))) - for log in logs: - bad = 'LOG.%s("Bad")' % log - self.assertEqual(1, - len(list( - checks.validate_log_translations(bad, bad, 'f')))) - ok = "LOG.%s('OK') # noqa" % log - self.assertEqual(0, - len(list( - checks.validate_log_translations(ok, ok, 'f')))) - ok = "LOG.%s(variable)" % log - self.assertEqual(0, - len(list( - checks.validate_log_translations(ok, ok, 'f')))) - for level in levels: - ok = "LOG.%s(%s('OK'))" % (log, level) - self.assertEqual(0, - len(list( - checks.validate_log_translations(ok, ok, 'f')))) - def test_no_mutable_default_args(self): self.assertEqual(1, len(list(checks.no_mutable_default_args( "def get_info_from_bdm(virt_type, bdm, mapping=[])"))))