From 4dddcf3643ae178dafccef5130f7c4e043e905df Mon Sep 17 00:00:00 2001 From: jichenjc Date: Thu, 5 Feb 2015 14:58:46 +0800 Subject: [PATCH] Treat LOG.warning and LOG.warn same 8510d3aaeeb18bdbe333d2d5d4c335f3732c4848 removed N331 checking, so now we need treat LOG.warn and LOG.warning same, so this patch adds the same checking to LOG.warn. Change-Id: Ifb3addfe116f8f7abb8750826b0217dfbd766439 --- HACKING.rst | 2 +- nova/hacking/checks.py | 6 ++---- nova/tests/unit/test_hacking.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index f96b9dfb9f99..3527cd235e02 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -39,7 +39,7 @@ Nova Specific Commandments - [N326] Translated messages cannot be concatenated. String should be included in translated message. - [N328] Validate that LOG.info messages use _LI. - [N329] Validate that LOG.exception messages use _LE. -- [N330] Validate that LOG.warning messages use _LW. +- [N330] Validate that LOG.warning and LOG.warn messages use _LW. - [N332] Check that the api_version decorator is the first decorator on a method - [N333] Check for oslo library imports use the non-namespaced packages - [N334] Change assertTrue/False(A in/not in B, message) to the more specific diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index e893f0ec3dde..9721f13d0d88 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -79,9 +79,7 @@ log_translation_info = re.compile( log_translation_exception = re.compile( r"(.)*LOG\.(exception)\(\s*(_\(|'|\")") log_translation_LW = re.compile( - r"(.)*LOG\.(warning)\(\s*(_\(|'|\")") -log_warn = re.compile( - r"(.)*LOG\.(warn)\(\s*('|\"|_)") + r"(.)*LOG\.(warning|warn)\(\s*(_\(|'|\")") translated_log = re.compile( r"(.)*LOG\.(audit|error|info|critical|exception)" "\(\s*_\(\s*('|\")") @@ -345,7 +343,7 @@ def validate_log_translations(logical_line, physical_line, filename): msg = "N329: LOG.exception messages require translations `_LE()`!" if log_translation_exception.match(logical_line): yield (0, msg) - msg = "N330: LOG.warning messages require translations `_LW()`!" + 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!" diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index c7ddafb1b79e..6b2b951189eb 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -211,7 +211,7 @@ class HackingTestCase(test.NoDBTestCase): "CONF.option = 1", "nova/compute/foo.py"))), 0) def test_log_translations(self): - logs = ['audit', 'error', 'info', 'warning', 'critical', + logs = ['audit', 'error', 'info', 'warning', 'critical', 'warn', 'exception'] levels = ['_LI', '_LW', '_LE', '_LC'] debug = "LOG.debug('OK')"