Fix issue with flake8 check and full paths

Currently hacking check_explicit_underscore_import is dependent
on a relative file path. A call of "flake8 ." works fine but
"flake8 $PWD" doesn't which shouldn't be any difference.

Change-Id: I7d40bbb771f96d28db38db69939de5e5993f3e9b
Closes-bug: #1530460
This commit is contained in:
Marc Koderer 2016-01-01 20:03:45 +01:00
parent c2315085e8
commit 0845300d19

View File

@ -32,7 +32,7 @@ Guidelines for writing new hacking checks
"""
# NOTE(thangp): Ignore N323 pep8 error caused by importing cinder objects
UNDERSCORE_IMPORT_FILES = ['./cinder/objects/__init__.py']
UNDERSCORE_IMPORT_FILES = ['cinder/objects/__init__.py']
translated_log = re.compile(
r"(.)*LOG\.(audit|error|info|warn|warning|critical|exception)"
@ -161,10 +161,11 @@ def check_explicit_underscore_import(logical_line, filename):
# Build a list of the files that have _ imported. No further
# checking needed once it is found.
if filename in UNDERSCORE_IMPORT_FILES:
pass
elif (underscore_import_check.match(logical_line) or
custom_underscore_check.match(logical_line)):
for file in UNDERSCORE_IMPORT_FILES:
if file in filename:
return
if (underscore_import_check.match(logical_line) or
custom_underscore_check.match(logical_line)):
UNDERSCORE_IMPORT_FILES.append(filename)
elif(translated_log.match(logical_line) or
string_translation.match(logical_line)):