Convert this file to snake case and update all files which use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
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:
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:
"""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.
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
# 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.
"""
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.
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:
"""
return self._boards
- def GetDict(self):
+ def get_dict(self):
"""Build a dictionary containing all the boards.
Returns:
board_dict[brd.target] = brd
return board_dict
- def GetSelectedDict(self):
+ def get_selected_dict(self):
"""Return a dictionary containing the selected boards
Returns:
board_dict[brd.target] = brd
return board_dict
- def GetSelected(self):
+ def get_selected(self):
"""Return a list of selected boards
Returns:
"""
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:
"""
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 '&'
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
"""
result = OrderedDict()
warnings = []
- terms = self._BuildTerms(args)
+ terms = self._build_terms(args)
result['all'] = []
for term in terms:
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
# 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
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))
sys.exit("Failed to generate boards.cfg")
brds = board.Boards()
- brds.ReadBoards(board_file)
+ brds.read_boards(board_file)
exclude = []
if options.exclude:
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'))
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
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 = []
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)
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(
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))
# 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)
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.
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']}, []))
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'],
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):