[U-Boot] [PATCH v6 16/20] patman: buildman: Correct spelling of 'colour'

Simon Glass
2014-08-09T21:33:12Z

This code came from another project. Correct the spelling now that it is
in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v6: None
Changes in v5: None
Changes in v4:
- Fix typo in commit message

Changes in v3:
- Add new patch to sort command line options

Changes in v2: None

tools/buildman/builder.py | 46 +++++++++++++++++++++---------------------
tools/buildman/control.py | 12 +++++------
tools/patman/checkpatch.py | 18 ++++++++---------
tools/patman/gitutil.py | 22 ++++++++++----------
tools/patman/patman.py | 4 ++--
tools/patman/series.py | 14 ++++++-------
tools/patman/terminal.py | 50 +++++++++++++++++++++++-----------------------
7 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index d5b8454..a65d1c3 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -105,7 +105,7 @@ class Builder:
base_dir: Base directory to use for builder
checkout: True to check out source, False to skip that step.
This is used for testing.
- col: terminal.Color() object
+ col: terminal.Colour() object
count: Number of commits to build
do_make: Method to call to invoke Make
fail: Number of builds that failed due to error
@@ -212,7 +212,7 @@ class Builder:
self.in_tree = False
self._error_lines = 0

- self.col = terminal.Color()
+ self.col = terminal.Colour()

self.queue = Queue.Queue()
self.out_queue = Queue.Queue()
@@ -325,7 +325,7 @@ class Builder:
result: A CommandResult object, which indicates the result for
a single build
"""
- col = terminal.Color()
+ col = terminal.Colour()
if result:
target = result.brd.target

@@ -353,9 +353,9 @@ class Builder:

# Display separate counts for ok, warned and fail
ok = self.upto - self.warned - self.fail
- line = '\r' + self.col.Color(self.col.GREEN, '%5d' % ok)
- line += self.col.Color(self.col.YELLOW, '%5d' % self.warned)
- line += self.col.Color(self.col.RED, '%5d' % self.fail)
+ line = '\r' + self.col.Colour(self.col.GREEN, '%5d' % ok)
+ line += self.col.Colour(self.col.YELLOW, '%5d' % self.warned)
+ line += self.col.Colour(self.col.RED, '%5d' % self.fail)

name = ' /%-5d ' % self.count

@@ -583,7 +583,7 @@ class Builder:
err_lines_summary.append(err.rstrip())
return board_dict, err_lines_summary

- def AddOutcome(self, board_dict, arch_list, changes, char, color):
+ def AddOutcome(self, board_dict, arch_list, changes, char, colour):
"""Add an output to our list of outcomes for each architecture

This simple function adds failing boards (changes) to the
@@ -595,7 +595,7 @@ class Builder:
arch_list: Dict keyed by arch name. Value is a string containing
a list of board names which failed for that arch.
changes: List of boards to add to arch_list
- color: terminal.Colour object
+ colour: terminal.Colour object
"""
done_arch = {}
for target in changes:
@@ -603,9 +603,9 @@ class Builder:
arch = board_dict[target].arch
else:
arch = 'unknown'
- str = self.col.Color(color, ' ' + target)
+ str = self.col.Colour(colour, ' ' + target)
if not arch in done_arch:
- str = self.col.Color(color, char) + ' ' + str
+ str = self.col.Colour(colour, char) + ' ' + str
done_arch[arch] = True
if not arch in arch_list:
arch_list[arch] = str
@@ -614,10 +614,10 @@ class Builder:

def ColourNum(self, num):
- color = self.col.RED if num > 0 else self.col.GREEN
+ colour = self.col.RED if num > 0 else self.col.GREEN
if num == 0:
return '0'
- return self.col.Color(color, str(num))
+ return self.col.Colour(colour, str(num))

def ResetResultSummary(self, board_selected):
"""Reset the results summary ready for use.
@@ -674,15 +674,15 @@ class Builder:
args = [self.ColourNum(x) for x in args]
indent = ' ' * 15
print ('%s%s: add: %s/%s, grow: %s/%s bytes: %s/%s (%s)' %
- tuple([indent, self.col.Color(self.col.YELLOW, fname)] + args))
+ tuple([indent, self.col.Colour(self.col.YELLOW, fname)] + args))
print '%s %-38s %7s %7s %+7s' % (indent, 'function', 'old', 'new',
'delta')
for diff, name in delta:
if diff:
- color = self.col.RED if diff > 0 else self.col.GREEN
+ colour = self.col.RED if diff > 0 else self.col.GREEN
msg = '%s %-38s %7s %7s %+7d' % (indent, name,
old.get(name, '-'), new.get(name,'-'), diff)
- print self.col.Color(color, msg)
+ print self.col.Colour(colour, msg)

def PrintSizeDetail(self, target_list, show_bloat):
@@ -704,12 +704,12 @@ class Builder:
if name.startswith('_'):
continue
if diff != 0:
- color = self.col.RED if diff > 0 else self.col.GREEN
+ colour = self.col.RED if diff > 0 else self.col.GREEN
msg = ' %s %+d' % (name, diff)
if not printed_target:
print '%10s %-15s:' % ('', result['_target']),
printed_target = True
- print self.col.Color(color, msg),
+ print self.col.Colour(colour, msg),
if printed_target:
print
if show_bloat:
@@ -813,13 +813,13 @@ class Builder:
# Display the average difference in this name for this
# architecture
avg_diff = float(diff) / count
- color = self.col.RED if avg_diff > 0 else self.col.GREEN
+ colour = self.col.RED if avg_diff > 0 else self.col.GREEN
msg = ' %s %+1.1f' % (name, avg_diff)
if not printed_arch:
print '%10s: (for %d/%d boards)' % (arch, count,
arch_count[arch]),
printed_arch = True
- print self.col.Color(color, msg),
+ print self.col.Colour(colour, msg),

if printed_arch:
print
@@ -894,10 +894,10 @@ class Builder:
print '%10s: %s' % (arch, target_list)
self._error_lines += 1
if better_err:
- print self.col.Color(self.col.GREEN, '\n'.join(better_err))
+ print self.col.Colour(self.col.GREEN, '\n'.join(better_err))
self._error_lines += 1
if worse_err:
- print self.col.Color(self.col.RED, '\n'.join(worse_err))
+ print self.col.Colour(self.col.RED, '\n'.join(worse_err))
self._error_lines += 1

if show_sizes:
@@ -923,7 +923,7 @@ class Builder:
if commits:
msg = '%02d: %s' % (commit_upto + 1,
commits[commit_upto].subject)
- print self.col.Color(self.col.BLUE, msg)
+ print self.col.Colour(self.col.BLUE, msg)
self.PrintResultSummary(board_selected, board_dict,
err_lines if self._show_errors else [],
self._show_sizes, self._show_detail, self._show_bloat)
@@ -946,7 +946,7 @@ class Builder:
for commit_upto in range(0, self.commit_count, self._step):
self.ProduceResultSummary(commit_upto, commits, board_selected)
if not self._error_lines:
- print self.col.Color(self.col.GREEN, '(no errors to report)')
+ print self.col.Colour(self.col.GREEN, '(no errors to report)')

def SetupBuild(self, board_selected, commits):
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 98a07a2..b11a215 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -55,7 +55,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options):
builder: The builder that will be used to build the commits
options: Command line options object
"""
- col = terminal.Color()
+ col = terminal.Colour()
print 'Dry run, so not doing much. But I would do this:'
print
if series:
@@ -68,7 +68,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options):
if commits:
for upto in range(0, len(series.commits), options.step):
commit = series.commits[upto]
- print ' ', col.Color(col.YELLOW, commit.hash, bright=False),
+ print ' ', col.Colour(col.YELLOW, commit.hash, bright=False),
print commit.subject
print
for arg in why_selected:
@@ -99,7 +99,7 @@ def DoBuildman(options, args):
# Work out how many commits to build. We want to build everything on the
# branch. We also build the upstream commit as a control so we can see
# problems introduced by the first commit on the branch.
- col = terminal.Color()
+ col = terminal.Colour()
count = options.count
if count == -1:
if not options.branch:
@@ -110,14 +110,14 @@ def DoBuildman(options, args):
if count is None:
str = ("Branch '%s' not found or has no upstream" %
options.branch)
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
sys.exit(1)
count += 1 # Build upstream commit also

if not count:
str = ("No commits found to process in branch '%s': "
"set branch's upstream or use -c flag" % options.branch)
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
sys.exit(1)

# Work out what subset of the boards we are building
@@ -135,7 +135,7 @@ def DoBuildman(options, args):
why_selected = boards.SelectBoards(args)
selected = boards.GetSelected()
if not len(selected):
- print col.Color(col.RED, 'No matching boards found')
+ print col.Colour(col.RED, 'No matching boards found')
sys.exit(1)

# Read the metadata from the commits. First look at the upstream commit,
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 0d4e935..c5c1603 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -133,17 +133,17 @@ def GetWarningMsg(col, msg_type, fname, line, msg):
msg: Message to report
'''
if msg_type == 'warning':
- msg_type = col.Color(col.YELLOW, msg_type)
+ msg_type = col.Colour(col.YELLOW, msg_type)
elif msg_type == 'error':
- msg_type = col.Color(col.RED, msg_type)
+ msg_type = col.Colour(col.RED, msg_type)
elif msg_type == 'check':
- msg_type = col.Color(col.MAGENTA, msg_type)
+ msg_type = col.Colour(col.MAGENTA, msg_type)
return '%s: %s,%d: %s' % (msg_type, fname, line, msg)

def CheckPatches(verbose, args):
'''Run the checkpatch.pl script on each patch'''
error_count, warning_count, check_count = 0, 0, 0
- col = terminal.Color()
+ col = terminal.Colour()

for fname in args:
result = CheckPatch(fname, verbose)
@@ -152,7 +152,7 @@ def CheckPatches(verbose, args):
warning_count += result.warnings
check_count += result.checks
print '%d errors, %d warnings, %d checks for %s:' % (result.errors,
- result.warnings, result.checks, col.Color(col.BLUE, fname))
+ result.warnings, result.checks, col.Colour(col.BLUE, fname))
if (len(result.problems) != result.errors + result.warnings +
result.checks):
print "Internal error: some problems lost"
@@ -164,11 +164,11 @@ def CheckPatches(verbose, args):
#print stdout
if error_count or warning_count or check_count:
str = 'checkpatch.pl found %d error(s), %d warning(s), %d checks(s)'
- color = col.GREEN
+ colour = col.GREEN
if warning_count:
- color = col.YELLOW
+ colour = col.YELLOW
if error_count:
- color = col.RED
- print col.Color(color, str % (error_count, warning_count, check_count))
+ colour = col.RED
+ print col.Colour(colour, str % (error_count, warning_count, check_count))
return False
return True
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 735c8dd..18133f2 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -221,7 +221,7 @@ def ApplyPatch(verbose, fname):
Args:
fname: filename of patch file to apply
"""
- col = terminal.Color()
+ col = terminal.Colour()
cmd = ['git', 'am', fname]
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -247,7 +247,7 @@ def ApplyPatches(verbose, args, start_point):
offset was given.
"""
error_count = 0
- col = terminal.Color()
+ col = terminal.Colour()

# Figure out our current position
cmd = ['git', 'name-rev', 'HEAD', '--name-only']
@@ -255,13 +255,13 @@ def ApplyPatches(verbose, args, start_point):
stdout, stderr = pipe.communicate()
if pipe.returncode:
str = 'Could not find current commit name'
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
print stdout
return False
old_head = stdout.splitlines()[0]
if old_head == 'undefined':
str = "Invalid HEAD '%s'" % stdout.strip()
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
return False

# Checkout the required start point
@@ -271,7 +271,7 @@ def ApplyPatches(verbose, args, start_point):
stdout, stderr = pipe.communicate()
if pipe.returncode:
str = 'Could not move to commit before patch series'
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
print stdout, stderr
return False

@@ -279,7 +279,7 @@ def ApplyPatches(verbose, args, start_point):
for fname in args:
ok, stdout = ApplyPatch(verbose, fname)
if not ok:
- print col.Color(col.RED, 'git am returned errors for %s: will '
+ print col.Colour(col.RED, 'git am returned errors for %s: will '
'skip this patch' % fname)
if verbose:
print stdout
@@ -288,7 +288,7 @@ def ApplyPatches(verbose, args, start_point):
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = pipe.communicate()
if pipe.returncode != 0:
- print col.Color(col.RED, 'Unable to skip patch! Aborting...')
+ print col.Colour(col.RED, 'Unable to skip patch! Aborting...')
print stdout
break

@@ -297,7 +297,7 @@ def ApplyPatches(verbose, args, start_point):
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = pipe.communicate()
if pipe.returncode:
- print col.Color(col.RED, 'Could not move back to head commit')
+ print col.Colour(col.RED, 'Could not move back to head commit')
print stdout, stderr
return error_count == 0

@@ -492,7 +492,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
return [lookup_name]

lookup_name = lookup_name.lower()
- col = terminal.Color()
+ col = terminal.Colour()

out_list = []
if level > 10:
@@ -500,7 +500,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
if raise_on_error:
raise OSError, msg
else:
- print col.Color(col.RED, msg)
+ print col.Colour(col.RED, msg)
return out_list

if lookup_name:
@@ -509,7 +509,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
if raise_on_error:
raise ValueError, msg
else:
- print col.Color(col.RED, msg)
+ print col.Colour(col.RED, msg)
return out_list
for item in alias[lookup_name]:
todo = LookupEmail(item, alias, raise_on_error, level + 1)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index c60aa5a..8fdedda 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -119,10 +119,10 @@ else:
# Work out how many patches to send if we can
options.count = gitutil.CountCommitsToBranch() - options.start

- col = terminal.Color()
+ col = terminal.Colour()
if not options.count:
str = 'No commits found to process - please use -c flag'
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
sys.exit(1)

# Read the metadata from the commits
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 88c0d87..40f908a 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -94,7 +94,7 @@ class Series(dict):
cmd: The git command we would have run
process_tags: Process tags as if they were aliases
"""
- col = terminal.Color()
+ col = terminal.Colour()
print 'Dry run, so not doing much. But I would do this:'
print
print 'Send a total of %d patch%s with %scover letter.' % (
@@ -104,7 +104,7 @@ class Series(dict):
# TODO: Colour the patches according to whether they passed checks
for upto in range(len(args)):
commit = self.commits[upto]
- print col.Color(col.GREEN, ' %s' % args[upto])
+ print col.Colour(col.GREEN, ' %s' % args[upto])
cc_list = list(self._generated_cc[commit.patch])

# Skip items in To list
@@ -116,7 +116,7 @@ class Series(dict):

for email in cc_list:
if email == None:
- email = col.Color(col.YELLOW, "<alias '%s' not found>"
+ email = col.Colour(col.YELLOW, "<alias '%s' not found>"
% tag)
if email:
print ' Cc: ',email
@@ -184,7 +184,7 @@ class Series(dict):

Print an error if something is wrong.
"""
- col = terminal.Color()
+ col = terminal.Colour()
if self.get('version'):
changes_copy = dict(self.changes)
for version in range(1, int(self.version) + 1):
@@ -193,13 +193,13 @@ class Series(dict):
else:
if version > 1:
str = 'Change log missing for v%d' % version
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
for version in changes_copy:
str = 'Change log for unknown version v%d' % version
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)
elif self.changes:
str = 'Change log exists, but no version is set'
- print col.Color(col.RED, str)
+ print col.Colour(col.RED, str)

def MakeCcFile(self, process_tags, cover_fname, raise_on_error):
"""Make a cc file for us to use for per-commit Cc automation
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py
index 597d526..5862aa1 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -5,17 +5,17 @@

"""Terminal utilities

-This module handles terminal interaction including ANSI color codes.
+This module handles terminal interaction including ANSI colour codes.
"""

import os
import sys

-# Selection of when we want our output to be colored
-COLOR_IF_TERMINAL, COLOR_ALWAYS, COLOR_NEVER = range(3)
+# Selection of when we want our output to be Coloured
+COLOUR_IF_TERMINAL, COLOUR_ALWAYS, COLOUR_NEVER = range(3)

-class Color(object):
- """Conditionally wraps text in ANSI color escape sequences."""
+class Colour(object):
+ """Conditionally wraps text in ANSI colour escape sequences."""
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
BOLD = -1
BRIGHT_START = '\033[1;%dm'
@@ -23,58 +23,58 @@ class Color(object):
BOLD_START = '\033[1m'
RESET = '\033[0m'

- def __init__(self, colored=COLOR_IF_TERMINAL):
- """Create a new Color object, optionally disabling color output.
+ def __init__(self, coloured=COLOUR_IF_TERMINAL):
+ """Create a new Colour object, optionally disabling colour output.

Args:
- enabled: True if color output should be enabled. If False then this
- class will not add color codes at all.
+ enabled: True if colour output should be enabled. If False then this
+ class will not add colour codes at all.
"""
- self._enabled = (colored == COLOR_ALWAYS or
- (colored == COLOR_IF_TERMINAL and os.isatty(sys.stdout.fileno())))
+ self._enabled = (coloured == COLOUR_ALWAYS or
+ (coloured == COLOUR_IF_TERMINAL and os.isatty(sys.stdout.fileno())))

- def Start(self, color, bright=True):
- """Returns a start color code.
+ def Start(self, colour, bright=True):
+ """Returns a start colour code.

Args:
- color: Color to use, .e.g BLACK, RED, etc.
+ colour: Colour to use, .e.g BLACK, RED, etc.

Returns:
- If color is enabled, returns an ANSI sequence to start the given color,
+ If colour is enabled, returns an ANSI sequence to start the given colour,
otherwise returns empty string
"""
if self._enabled:
base = self.BRIGHT_START if bright else self.NORMAL_START
- return base % (color + 30)
+ return base % (colour + 30)
return ''

def Stop(self):
- """Retruns a stop color code.
+ """Retruns a stop colour code.

Returns:
- If color is enabled, returns an ANSI color reset sequence, otherwise
+ If colour is enabled, returns an ANSI colour reset sequence, otherwise
returns empty string
"""
if self._enabled:
return self.RESET
return ''

- def Color(self, color, text, bright=True):
- """Returns text with conditionally added color escape sequences.
+ def Colour(self, colour, text, bright=True):
+ """Returns text with conditionally added colour escape sequences.

Keyword arguments:
- color: Text color -- one of the color constants defined in this class.
- text: The text to color.
+ colour: Text colour -- one of the colour constants defined in this class.
+ text: The text to colour.

Returns:
If self._enabled is False, returns the original text. If it's True,
- returns text with color escape sequences based on the value of color.
+ returns text with colour escape sequences based on the value of colour.
"""
if not self._enabled:
return text
- if color == self.BOLD:
+ if colour == self.BOLD:
start = self.BOLD_START
else:
base = self.BRIGHT_START if bright else self.NORMAL_START
- start = base % (color + 30)
+ start = base % (colour + 30)
return start + text + self.RESET
--
2.0.0.526.g5318336