Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def input_file(self, filename, lines=None, expected=None, line_offset=0):
if lines is None:
assert line_offset == 0
line_offset = LINES_SKIP
lines = pep8.readlines(filename)[LINES_SKIP:]
return super(PEP8, self).input_file(
filename, lines=lines, expected=expected, line_offset=line_offset)
def input_file(self, filename, lines=None, expected=None, line_offset=0):
if lines is None:
assert line_offset == 0
line_offset = LINES_SKIP
lines = pep8.readlines(filename)[LINES_SKIP:]
return super(PEP8, self).input_file(
filename, lines=lines, expected=expected, line_offset=line_offset)
Okay: from foo.bar.yourclass import YourClass
Okay: import myclass
Okay: import foo.bar.yourclass
"""
if __name__ == "__main__":
#include nova path
sys.path.append(os.getcwd())
#Run once tests (not per line)
once_error = once_git_check_commit_title()
#NOVA error codes start with an N
pep8.SELFTEST_REGEX = re.compile(r'(Okay|[EWN]\d{3}):\s(.*)')
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_nova()
pep8.current_file = current_file
pep8.readlines = readlines
pep8.StyleGuide.excluded = excluded
pep8.StyleGuide.input_dir = input_dir
# we need to kill this doctring otherwise the self tests fail
pep8.imports_on_separate_lines.__doc__ = \
imports_on_separate_lines_N301_compliant
try:
pep8._main()
sys.exit(once_error)
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
% len(_missingImport))
Okay: import myclass
Okay: import foo.bar.yourclass
"""
if __name__ == "__main__":
gettext.install('ceilometer', unicode=True)
#include nova path
sys.path.append(os.getcwd())
#Run once tests (not per line)
once_error = once_git_check_commit_title()
#NOVA error codes start with an N
pep8.SELFTEST_REGEX = re.compile(r'(Okay|[EWN]\d{3}):\s(.*)')
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_nova()
pep8.current_file = current_file
pep8.readlines = readlines
pep8.StyleGuide.excluded = excluded
pep8.StyleGuide.input_dir = input_dir
# we need to kill this doctring otherwise the self tests fail
pep8.imports_on_separate_lines.__doc__ = \
imports_on_separate_lines_N301_compliant
try:
pep8._main()
sys.exit(once_error)
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
% len(_missingImport))
Okay: import myclass
Okay: import foo.bar.yourclass
"""
if __name__ == "__main__":
gettext.install('nova', unicode=1)
#include nova path
sys.path.append(os.getcwd())
#Run once tests (not per line)
once_error = once_git_check_commit_title()
#NOVA error codes start with an N
pep8.SELFTEST_REGEX = re.compile(r'(Okay|[EWN]\d{3}):\s(.*)')
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_nova()
pep8.current_file = current_file
pep8.readlines = readlines
pep8.StyleGuide.excluded = excluded
pep8.StyleGuide.input_dir = input_dir
# we need to kill this doctring otherwise the self tests fail
pep8.imports_on_separate_lines.__doc__ = \
imports_on_separate_lines_N301_compliant
try:
pep8._main()
sys.exit(once_error)
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
% len(_missingImport))
if len(title.decode('utf-8')) > 72:
print ("T802: git commit title ('%s') should be under 50 chars"
% title.strip())
error = True
return error
if __name__ == "__main__":
#include tempest path
sys.path.append(os.getcwd())
#Run once tests (not per line)
once_error = once_git_check_commit_title()
#TEMPEST error codes start with a T
pep8.ERRORCODE_REGEX = re.compile(r'[EWT]\d{3}')
add_tempest()
pep8.current_file = current_file
pep8.readlines = readlines
pep8.StyleGuide.excluded = excluded
pep8.StyleGuide.input_dir = input_dir
try:
pep8._main()
sys.exit(once_error)
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
% len(_missingImport))
Assumes you know how to write pep8.py checks
"""
for name, function in globals().items():
if not inspect.isfunction(function):
continue
if name.startswith("cloud_"):
exec("pep8.%s = %s" % (name, name))
if __name__ == "__main__":
# NOVA based 'hacking.py' error codes start with an N
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_cloud()
pep8.current_file = current_file
pep8.readlines = readlines
try:
pep8._main()
finally:
if len(_missingImport) > 0:
sys.stderr.write(
"%i imports missing in this test environment\n" %
len(_missingImport))
def compile_file(filename):
"""
Compile file and return AST tree.
"""
try:
lines = readlines(filename)
except IOError:
return
else:
code = ''.join(lines)
try:
return compile(code, '', 'exec', ast.PyCF_ONLY_AST, True)
except (SyntaxError, TypeError):
return
"""
for name, function in globals().items():
if not inspect.isfunction(function):
continue
args = inspect.getargspec(function)[0]
if args and name.startswith("cinder"):
exec("pep8.%s = %s" % (name, name))
if __name__ == "__main__":
#include cinder path
sys.path.append(os.getcwd())
#CINDER error codes start with an N
pep8.ERRORCODE_REGEX = re.compile(r'[EWN]\d{3}')
add_cinder()
pep8.current_file = current_file
pep8.readlines = readlines
try:
pep8._main()
finally:
if len(_missingImport) > 0:
print >> sys.stderr, ("%i imports missing in this test environment"
% len(_missingImport))