Remove hacking check for log translation

The I18n translation team has removed log translations, so our
enforcement of the _Lx translation markers is no longer required.

See:
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html

Change-Id: I54a57ed832d440f6e0c7c39cb59f03ca443dfeda
This commit is contained in:
Sean McGinnis 2017-03-09 15:44:20 -06:00
parent 408dd4aa30
commit 872ff1e25e
3 changed files with 1 additions and 52 deletions

View File

@ -12,9 +12,6 @@ Cinder Specific Commandments
- [N322] Ensure default arguments are not mutable.
- [N323] Add check for explicit import of _() to ensure proper translation.
- [N325] str() and unicode() cannot be used on an exception. Remove or use six.text_type().
- [N328] LOG.info messages require translations `_LI()`.
- [N329] LOG.exception and LOG.error messages require translations `_LE()`.
- [N330] LOG.warning messages require translations `_LW()`.
- [N336] Must use a dict comprehension instead of a dict constructor with a sequence of key-value pairs.
- [C301] timeutils.utcnow() from oslo_utils should be used instead of datetime.now().
- [C302] six.text_type should be used instead of unicode.

View File

@ -54,12 +54,6 @@ oslo_namespace_imports = re.compile(r"from[\s]*oslo[.](concurrency|db"
"|config|utils|serialization|log)")
no_contextlib_nested = re.compile(r"\s*with (contextlib\.)?nested\(")
log_translation_LI = re.compile(
r"(.)*LOG\.(info)\(\s*(_\(|'|\")")
log_translation_LE = re.compile(
r"(.)*LOG\.(exception|error)\(\s*(_\(|'|\")")
log_translation_LW = re.compile(
r"(.)*LOG\.(warning|warn)\(\s*(_\(|'|\")")
logging_instance = re.compile(
r"(.)*LOG\.(warning|info|debug|error|exception)\(")
@ -366,24 +360,6 @@ class CheckOptRegistrationArgs(BaseASTChecker):
return super(CheckOptRegistrationArgs, self).generic_visit(node)
def validate_log_translations(logical_line, filename):
# Translations are not required in the test directory.
# This will not catch all instances of violations, just direct
# misuse of the form LOG.info('Message').
if "cinder/tests" in filename:
return
msg = "N328: LOG.info messages require translations `_LI()`!"
if log_translation_LI.match(logical_line):
yield (0, msg)
msg = ("N329: LOG.exception and LOG.error messages require "
"translations `_LE()`!")
if log_translation_LE.match(logical_line):
yield (0, msg)
msg = "N330: LOG.warning messages require translations `_LW()`!"
if log_translation_LW.match(logical_line):
yield (0, msg)
def check_datetime_now(logical_line, noqa):
if noqa:
return
@ -496,7 +472,6 @@ def factory(register):
register(check_datetime_now)
register(check_timeutils_strtime)
register(check_timeutils_isotime)
register(validate_log_translations)
register(check_unicode_usage)
register(check_no_print_statements)
register(check_no_log_audit)

View File

@ -105,7 +105,7 @@ class HackingTestCase(test.TestCase):
"msg = _('My message')",
"cinder.tests.unit/other_files.py"))))
self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
"from cinder.i18n import _LE, _, _LW",
"from cinder.i18n import _",
"cinder.tests.unit/other_files2.py"))))
self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
"msg = _('My message')",
@ -120,9 +120,6 @@ class HackingTestCase(test.TestCase):
self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
"LOG.info('My info message')",
"cinder.tests.unit/other_files4.py"))))
self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
"from cinder.i18n import _LW",
"cinder.tests.unit/other_files5.py"))))
self.assertEqual(1, len(list(checks.check_explicit_underscore_import(
"msg = _('My message')",
"cinder.tests.unit/other_files5.py"))))
@ -310,26 +307,6 @@ class HackingTestCase(test.TestCase):
self.assertEqual(0, len(list(checks.check_timeutils_strtime(
"strftime"))))
def test_validate_log_translations(self):
self.assertEqual(1, len(list(checks.validate_log_translations(
"LOG.info('foo')", "foo.py"))))
self.assertEqual(1, len(list(checks.validate_log_translations(
"LOG.warning('foo')", "foo.py"))))
self.assertEqual(1, len(list(checks.validate_log_translations(
"LOG.error('foo')", "foo.py"))))
self.assertEqual(1, len(list(checks.validate_log_translations(
"LOG.exception('foo')", "foo.py"))))
self.assertEqual(0, len(list(checks.validate_log_translations(
"LOG.info('foo')", "cinder/tests/foo.py"))))
self.assertEqual(0, len(list(checks.validate_log_translations(
"LOG.info(_LI('foo')", "foo.py"))))
self.assertEqual(0, len(list(checks.validate_log_translations(
"LOG.warning(_LW('foo')", "foo.py"))))
self.assertEqual(0, len(list(checks.validate_log_translations(
"LOG.error(_LE('foo')", "foo.py"))))
self.assertEqual(0, len(list(checks.validate_log_translations(
"LOG.exception(_LE('foo')", "foo.py"))))
def test_check_unicode_usage(self):
self.assertEqual(1, len(list(checks.check_unicode_usage(
"unicode(msg)", False))))