mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-03-16 23:07:00 +00:00
buildman: Convert camel case in board.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
fb5cb07abe
commit
6014db68d3
4 changed files with 42 additions and 42 deletions
|
@ -16,7 +16,7 @@ class Expr:
|
|||
self._expr = expr
|
||||
self._re = re.compile(expr)
|
||||
|
||||
def Matches(self, props):
|
||||
def matches(self, props):
|
||||
"""Check if any of the properties match the regular expression.
|
||||
|
||||
Args:
|
||||
|
@ -42,7 +42,7 @@ class Term:
|
|||
self._expr_list = []
|
||||
self._board_count = 0
|
||||
|
||||
def AddExpr(self, expr):
|
||||
def add_expr(self, expr):
|
||||
"""Add an Expr object to the list to check.
|
||||
|
||||
Args:
|
||||
|
@ -55,7 +55,7 @@ class Term:
|
|||
"""Return some sort of useful string describing the term"""
|
||||
return '&'.join([str(expr) for expr in self._expr_list])
|
||||
|
||||
def Matches(self, props):
|
||||
def matches(self, props):
|
||||
"""Check if any of the properties match this term
|
||||
|
||||
Each of the expressions in the term is checked. All must match.
|
||||
|
@ -66,7 +66,7 @@ class Term:
|
|||
True if all of the expressions in the Term match, else False
|
||||
"""
|
||||
for expr in self._expr_list:
|
||||
if not expr.Matches(props):
|
||||
if not expr.matches(props):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -103,7 +103,7 @@ class Boards:
|
|||
# Use a simple list here, sinc OrderedDict requires Python 2.7
|
||||
self._boards = []
|
||||
|
||||
def AddBoard(self, brd):
|
||||
def add_board(self, brd):
|
||||
"""Add a new board to the list.
|
||||
|
||||
The board's target member must not already exist in the board list.
|
||||
|
@ -113,7 +113,7 @@ class Boards:
|
|||
"""
|
||||
self._boards.append(brd)
|
||||
|
||||
def ReadBoards(self, fname):
|
||||
def read_boards(self, fname):
|
||||
"""Read a list of boards from a board file.
|
||||
|
||||
Create a Board object for each and add it to our _boards list.
|
||||
|
@ -137,10 +137,10 @@ class Boards:
|
|||
fields = fields[:8]
|
||||
|
||||
brd = Board(*fields)
|
||||
self.AddBoard(brd)
|
||||
self.add_board(brd)
|
||||
|
||||
|
||||
def GetList(self):
|
||||
def get_list(self):
|
||||
"""Return a list of available boards.
|
||||
|
||||
Returns:
|
||||
|
@ -148,7 +148,7 @@ class Boards:
|
|||
"""
|
||||
return self._boards
|
||||
|
||||
def GetDict(self):
|
||||
def get_dict(self):
|
||||
"""Build a dictionary containing all the boards.
|
||||
|
||||
Returns:
|
||||
|
@ -161,7 +161,7 @@ class Boards:
|
|||
board_dict[brd.target] = brd
|
||||
return board_dict
|
||||
|
||||
def GetSelectedDict(self):
|
||||
def get_selected_dict(self):
|
||||
"""Return a dictionary containing the selected boards
|
||||
|
||||
Returns:
|
||||
|
@ -173,7 +173,7 @@ class Boards:
|
|||
board_dict[brd.target] = brd
|
||||
return board_dict
|
||||
|
||||
def GetSelected(self):
|
||||
def get_selected(self):
|
||||
"""Return a list of selected boards
|
||||
|
||||
Returns:
|
||||
|
@ -181,7 +181,7 @@ class Boards:
|
|||
"""
|
||||
return [brd for brd in self._boards if brd.build_it]
|
||||
|
||||
def GetSelectedNames(self):
|
||||
def get_selected_names(self):
|
||||
"""Return a list of selected boards
|
||||
|
||||
Returns:
|
||||
|
@ -189,7 +189,7 @@ class Boards:
|
|||
"""
|
||||
return [brd.target for brd in self._boards if brd.build_it]
|
||||
|
||||
def _BuildTerms(self, args):
|
||||
def _build_terms(self, args):
|
||||
"""Convert command line arguments to a list of terms.
|
||||
|
||||
This deals with parsing of the arguments. It handles the '&'
|
||||
|
@ -227,18 +227,18 @@ class Boards:
|
|||
if sym == '&':
|
||||
oper = sym
|
||||
elif oper:
|
||||
term.AddExpr(sym)
|
||||
term.add_expr(sym)
|
||||
oper = None
|
||||
else:
|
||||
if term:
|
||||
terms.append(term)
|
||||
term = Term()
|
||||
term.AddExpr(sym)
|
||||
term.add_expr(sym)
|
||||
if term:
|
||||
terms.append(term)
|
||||
return terms
|
||||
|
||||
def SelectBoards(self, args, exclude=[], brds=None):
|
||||
def select_boards(self, args, exclude=[], brds=None):
|
||||
"""Mark boards selected based on args
|
||||
|
||||
Normally either boards (an explicit list of boards) or args (a list of
|
||||
|
@ -262,7 +262,7 @@ class Boards:
|
|||
"""
|
||||
result = OrderedDict()
|
||||
warnings = []
|
||||
terms = self._BuildTerms(args)
|
||||
terms = self._build_terms(args)
|
||||
|
||||
result['all'] = []
|
||||
for term in terms:
|
||||
|
@ -279,7 +279,7 @@ class Boards:
|
|||
if terms:
|
||||
match = False
|
||||
for term in terms:
|
||||
if term.Matches(brd.props):
|
||||
if term.matches(brd.props):
|
||||
matching_term = str(term)
|
||||
build_it = True
|
||||
break
|
||||
|
@ -292,7 +292,7 @@ class Boards:
|
|||
|
||||
# Check that it is not specifically excluded
|
||||
for expr in exclude_list:
|
||||
if expr.Matches(brd.props):
|
||||
if expr.matches(brd.props):
|
||||
build_it = False
|
||||
break
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ def ShowToolchainPrefix(brds, toolchains):
|
|||
Return:
|
||||
None on success, string error message otherwise
|
||||
"""
|
||||
board_selected = brds.GetSelectedDict()
|
||||
board_selected = brds.get_selected_dict()
|
||||
tc_set = set()
|
||||
for brd in board_selected.values():
|
||||
tc_set.add(toolchains.Select(brd.arch))
|
||||
|
@ -198,7 +198,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||
sys.exit("Failed to generate boards.cfg")
|
||||
|
||||
brds = board.Boards()
|
||||
brds.ReadBoards(board_file)
|
||||
brds.read_boards(board_file)
|
||||
|
||||
exclude = []
|
||||
if options.exclude:
|
||||
|
@ -211,9 +211,9 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||
requested_boards += b.split(',')
|
||||
else:
|
||||
requested_boards = None
|
||||
why_selected, board_warnings = brds.SelectBoards(args, exclude,
|
||||
requested_boards)
|
||||
selected = brds.GetSelected()
|
||||
why_selected, board_warnings = brds.select_boards(args, exclude,
|
||||
requested_boards)
|
||||
selected = brds.get_selected()
|
||||
if not len(selected):
|
||||
sys.exit(col.build(col.RED, 'No matching boards found'))
|
||||
|
||||
|
@ -349,7 +349,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||
builder.in_tree = options.in_tree
|
||||
|
||||
# Work out which boards to build
|
||||
board_selected = brds.GetSelectedDict()
|
||||
board_selected = brds.get_selected_dict()
|
||||
|
||||
if series:
|
||||
commits = series.commits
|
||||
|
|
|
@ -189,7 +189,7 @@ class TestFunctional(unittest.TestCase):
|
|||
self._toolchains.Add('powerpc-gcc', test=False)
|
||||
self._boards = board.Boards()
|
||||
for brd in BOARDS:
|
||||
self._boards.AddBoard(board.Board(*brd))
|
||||
self._boards.add_board(board.Board(*brd))
|
||||
|
||||
# Directories where the source been cloned
|
||||
self._clone_dirs = []
|
||||
|
@ -476,7 +476,7 @@ class TestFunctional(unittest.TestCase):
|
|||
self.assertEqual(ret_code, 100)
|
||||
|
||||
for commit in range(self._commits):
|
||||
for brd in self._boards.GetList():
|
||||
for brd in self._boards.get_list():
|
||||
if brd.arch != 'sandbox':
|
||||
errfile = self._builder.GetErrFile(commit, brd.target)
|
||||
fd = open(errfile)
|
||||
|
@ -581,7 +581,7 @@ class TestFunctional(unittest.TestCase):
|
|||
def testWorkInOutput(self):
|
||||
"""Test the -w option which should write directly to the output dir"""
|
||||
board_list = board.Boards()
|
||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
||||
board_list.add_board(board.Board(*BOARDS[0]))
|
||||
self._RunControl('-o', self._output_dir, '-w', clean_dir=False,
|
||||
brds=board_list)
|
||||
self.assertTrue(
|
||||
|
@ -600,14 +600,14 @@ class TestFunctional(unittest.TestCase):
|
|||
os.path.exists(os.path.join(self._output_dir, 'u-boot')))
|
||||
|
||||
board_list = board.Boards()
|
||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
||||
board_list.add_board(board.Board(*BOARDS[0]))
|
||||
with self.assertRaises(SystemExit) as e:
|
||||
self._RunControl('-b', self._test_branch, '-o', self._output_dir,
|
||||
'-w', clean_dir=False, brds=board_list)
|
||||
self.assertIn("single commit", str(e.exception))
|
||||
|
||||
board_list = board.Boards()
|
||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
||||
board_list.add_board(board.Board(*BOARDS[0]))
|
||||
with self.assertRaises(SystemExit) as e:
|
||||
self._RunControl('-w', clean_dir=False)
|
||||
self.assertIn("specify -o", str(e.exception))
|
||||
|
|
|
@ -133,8 +133,8 @@ class TestBuild(unittest.TestCase):
|
|||
# Set up boards to build
|
||||
self.brds = board.Boards()
|
||||
for brd in BOARDS:
|
||||
self.brds.AddBoard(board.Board(*brd))
|
||||
self.brds.SelectBoards([])
|
||||
self.brds.add_board(board.Board(*brd))
|
||||
self.brds.select_boards([])
|
||||
|
||||
# Add some test settings
|
||||
bsettings.Setup(None)
|
||||
|
@ -203,7 +203,7 @@ class TestBuild(unittest.TestCase):
|
|||
build = builder.Builder(self.toolchains, self.base_dir, None, threads,
|
||||
2, checkout=False, show_unknown=False)
|
||||
build.do_make = self.Make
|
||||
board_selected = self.brds.GetSelectedDict()
|
||||
board_selected = self.brds.get_selected_dict()
|
||||
|
||||
# Build the boards for the pre-defined commits and warnings/errors
|
||||
# associated with each. This calls our Make() to inject the fake output.
|
||||
|
@ -468,18 +468,18 @@ class TestBuild(unittest.TestCase):
|
|||
|
||||
def testBoardSingle(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['sandbox']),
|
||||
self.assertEqual(self.brds.select_boards(['sandbox']),
|
||||
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
||||
|
||||
def testBoardArch(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['arm']),
|
||||
self.assertEqual(self.brds.select_boards(['arm']),
|
||||
({'all': ['board0', 'board1'],
|
||||
'arm': ['board0', 'board1']}, []))
|
||||
|
||||
def testBoardArchSingle(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['arm sandbox']),
|
||||
self.assertEqual(self.brds.select_boards(['arm sandbox']),
|
||||
({'sandbox': ['board4'],
|
||||
'all': ['board0', 'board1', 'board4'],
|
||||
'arm': ['board0', 'board1']}, []))
|
||||
|
@ -487,20 +487,20 @@ class TestBuild(unittest.TestCase):
|
|||
|
||||
def testBoardArchSingleMultiWord(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['arm', 'sandbox']),
|
||||
self.assertEqual(self.brds.select_boards(['arm', 'sandbox']),
|
||||
({'sandbox': ['board4'],
|
||||
'all': ['board0', 'board1', 'board4'],
|
||||
'arm': ['board0', 'board1']}, []))
|
||||
|
||||
def testBoardSingleAnd(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['Tester & arm']),
|
||||
self.assertEqual(self.brds.select_boards(['Tester & arm']),
|
||||
({'Tester&arm': ['board0', 'board1'],
|
||||
'all': ['board0', 'board1']}, []))
|
||||
|
||||
def testBoardTwoAnd(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['Tester', '&', 'arm',
|
||||
self.assertEqual(self.brds.select_boards(['Tester', '&', 'arm',
|
||||
'Tester' '&', 'powerpc',
|
||||
'sandbox']),
|
||||
({'sandbox': ['board4'],
|
||||
|
@ -511,19 +511,19 @@ class TestBuild(unittest.TestCase):
|
|||
|
||||
def testBoardAll(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards([]),
|
||||
self.assertEqual(self.brds.select_boards([]),
|
||||
({'all': ['board0', 'board1', 'board2', 'board3',
|
||||
'board4']}, []))
|
||||
|
||||
def testBoardRegularExpression(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['T.*r&^Po']),
|
||||
self.assertEqual(self.brds.select_boards(['T.*r&^Po']),
|
||||
({'all': ['board2', 'board3'],
|
||||
'T.*r&^Po': ['board2', 'board3']}, []))
|
||||
|
||||
def testBoardDuplicate(self):
|
||||
"""Test single board selection"""
|
||||
self.assertEqual(self.brds.SelectBoards(['sandbox sandbox',
|
||||
self.assertEqual(self.brds.select_boards(['sandbox sandbox',
|
||||
'sandbox']),
|
||||
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
||||
def CheckDirs(self, build, dirname):
|
||||
|
|
Loading…
Add table
Reference in a new issue