mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-17 22:49:02 +00:00
patman: Convert camel case in checkpatch.py
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d98006997c
commit
ae5e926550
3 changed files with 18 additions and 18 deletions
|
@ -20,7 +20,7 @@ RE_FILE = re.compile(r'#(\d+): (FILE: ([^:]*):(\d+):)?')
|
|||
RE_NOTE = re.compile(r'NOTE: (.*)')
|
||||
|
||||
|
||||
def FindCheckPatch():
|
||||
def find_check_patch():
|
||||
top_level = gitutil.GetTopLevel()
|
||||
try_list = [
|
||||
os.getcwd(),
|
||||
|
@ -47,7 +47,7 @@ def FindCheckPatch():
|
|||
'~/bin directory or use --no-check')
|
||||
|
||||
|
||||
def CheckPatchParseOneMessage(message):
|
||||
def check_patch_parse_one_message(message):
|
||||
"""Parse one checkpatch message
|
||||
|
||||
Args:
|
||||
|
@ -114,7 +114,7 @@ def CheckPatchParseOneMessage(message):
|
|||
return item
|
||||
|
||||
|
||||
def CheckPatchParse(checkpatch_output, verbose=False):
|
||||
def check_patch_parse(checkpatch_output, verbose=False):
|
||||
"""Parse checkpatch.pl output
|
||||
|
||||
Args:
|
||||
|
@ -179,14 +179,14 @@ def CheckPatchParse(checkpatch_output, verbose=False):
|
|||
elif re_bad.match(message):
|
||||
result.ok = False
|
||||
else:
|
||||
problem = CheckPatchParseOneMessage(message)
|
||||
problem = check_patch_parse_one_message(message)
|
||||
if problem:
|
||||
result.problems.append(problem)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def CheckPatch(fname, verbose=False, show_types=False):
|
||||
def check_patch(fname, verbose=False, show_types=False):
|
||||
"""Run checkpatch.pl on a file and parse the results.
|
||||
|
||||
Args:
|
||||
|
@ -209,16 +209,16 @@ def CheckPatch(fname, verbose=False, show_types=False):
|
|||
lines: Number of lines
|
||||
stdout: Full output of checkpatch
|
||||
"""
|
||||
chk = FindCheckPatch()
|
||||
chk = find_check_patch()
|
||||
args = [chk, '--no-tree']
|
||||
if show_types:
|
||||
args.append('--show-types')
|
||||
output = command.output(*args, fname, raise_on_error=False)
|
||||
|
||||
return CheckPatchParse(output, verbose)
|
||||
return check_patch_parse(output, verbose)
|
||||
|
||||
|
||||
def GetWarningMsg(col, msg_type, fname, line, msg):
|
||||
def get_warning_msg(col, msg_type, fname, line, msg):
|
||||
'''Create a message for a given file/line
|
||||
|
||||
Args:
|
||||
|
@ -236,13 +236,13 @@ def GetWarningMsg(col, msg_type, fname, line, msg):
|
|||
line_str = '' if line is None else '%d' % line
|
||||
return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg)
|
||||
|
||||
def CheckPatches(verbose, args):
|
||||
def check_patches(verbose, args):
|
||||
'''Run the checkpatch.pl script on each patch'''
|
||||
error_count, warning_count, check_count = 0, 0, 0
|
||||
col = terminal.Color()
|
||||
|
||||
for fname in args:
|
||||
result = CheckPatch(fname, verbose)
|
||||
result = check_patch(fname, verbose)
|
||||
if not result.ok:
|
||||
error_count += result.errors
|
||||
warning_count += result.warnings
|
||||
|
@ -254,7 +254,7 @@ def CheckPatches(verbose, args):
|
|||
print("Internal error: some problems lost")
|
||||
for item in result.problems:
|
||||
sys.stderr.write(
|
||||
GetWarningMsg(col, item.get('type', '<unknown>'),
|
||||
get_warning_msg(col, item.get('type', '<unknown>'),
|
||||
item.get('file', '<unknown>'),
|
||||
item.get('line', 0), item.get('msg', 'message')))
|
||||
print
|
||||
|
|
|
@ -86,7 +86,7 @@ def check_patches(series, patch_files, run_checkpatch, verbose):
|
|||
|
||||
# Check the patches, and run them through 'git am' just to be sure
|
||||
if run_checkpatch:
|
||||
ok = checkpatch.CheckPatches(verbose, patch_files)
|
||||
ok = checkpatch.check_patches(verbose, patch_files)
|
||||
else:
|
||||
ok = True
|
||||
return ok
|
||||
|
|
|
@ -82,7 +82,7 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
|
|||
return inname
|
||||
|
||||
def run_checkpatch(self):
|
||||
return checkpatch.CheckPatch(self.get_patch(), show_types=True)
|
||||
return checkpatch.check_patch(self.get_patch(), show_types=True)
|
||||
|
||||
|
||||
class TestPatch(unittest.TestCase):
|
||||
|
@ -295,7 +295,7 @@ index 0000000..2234c87
|
|||
def testGood(self):
|
||||
"""Test checkpatch operation"""
|
||||
inf = self.SetupData('good')
|
||||
result = checkpatch.CheckPatch(inf)
|
||||
result = checkpatch.check_patch(inf)
|
||||
self.assertEqual(result.ok, True)
|
||||
self.assertEqual(result.problems, [])
|
||||
self.assertEqual(result.errors, 0)
|
||||
|
@ -306,7 +306,7 @@ index 0000000..2234c87
|
|||
|
||||
def testNoSignoff(self):
|
||||
inf = self.SetupData('no-signoff')
|
||||
result = checkpatch.CheckPatch(inf)
|
||||
result = checkpatch.check_patch(inf)
|
||||
self.assertEqual(result.ok, False)
|
||||
self.assertEqual(len(result.problems), 1)
|
||||
self.assertEqual(result.errors, 1)
|
||||
|
@ -317,7 +317,7 @@ index 0000000..2234c87
|
|||
|
||||
def testNoLicense(self):
|
||||
inf = self.SetupData('no-license')
|
||||
result = checkpatch.CheckPatch(inf)
|
||||
result = checkpatch.check_patch(inf)
|
||||
self.assertEqual(result.ok, False)
|
||||
self.assertEqual(len(result.problems), 1)
|
||||
self.assertEqual(result.errors, 0)
|
||||
|
@ -328,7 +328,7 @@ index 0000000..2234c87
|
|||
|
||||
def testSpaces(self):
|
||||
inf = self.SetupData('spaces')
|
||||
result = checkpatch.CheckPatch(inf)
|
||||
result = checkpatch.check_patch(inf)
|
||||
self.assertEqual(result.ok, False)
|
||||
self.assertEqual(len(result.problems), 3)
|
||||
self.assertEqual(result.errors, 0)
|
||||
|
@ -339,7 +339,7 @@ index 0000000..2234c87
|
|||
|
||||
def testIndent(self):
|
||||
inf = self.SetupData('indent')
|
||||
result = checkpatch.CheckPatch(inf)
|
||||
result = checkpatch.check_patch(inf)
|
||||
self.assertEqual(result.ok, False)
|
||||
self.assertEqual(len(result.problems), 1)
|
||||
self.assertEqual(result.errors, 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue