From b0ba4593a379c01a1ea420414d58f1ba81fac11f Mon Sep 17 00:00:00 2001 From: Alexandru Coman Date: Wed, 9 Jul 2014 11:06:37 +0300 Subject: [PATCH] Code refactoring. --- checkers/misc.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/checkers/misc.py b/checkers/misc.py index 45ed348b4..3afe63bcd 100644 --- a/checkers/misc.py +++ b/checkers/misc.py @@ -54,11 +54,10 @@ class EncodingChecker(BaseChecker): 'separated by a comma.')}),) def _check_note(self, notes, lineno, line): - for note in notes: - match = note.search(line) - if not match: - continue - self.add_message('fixme', args=match.group(1).strip(), line=lineno) + match = notes.search(line) + if not match: + return + self.add_message('fixme', args=line[match.start(1):-1], line=lineno) def _check_encoding(self, lineno, line, file_encoding): try: @@ -74,8 +73,8 @@ class EncodingChecker(BaseChecker): stream = module.file_stream stream.seek(0) # XXX may be removed with astroid > 0.23 if self.config.notes: - notes = [re.compile(r'.*?#\s+({}:*\s*.+)'.format(note)) - for note in self.config.notes] + notes = re.compile(r'.*?#\s+({})(:*\s*.+)'.format( + "|".join(self.config.notes))) else: notes = None if module.file_encoding: