Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09CCCC433EF for ; Tue, 12 Jul 2022 01:06:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 526DA840A8; Tue, 12 Jul 2022 03:05:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Mdlur6hr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8DBD4840D2; Tue, 12 Jul 2022 03:04:54 +0200 (CEST) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A1BA78408A for ; Tue, 12 Jul 2022 03:04:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-wr1-x429.google.com with SMTP id h17so9146897wrx.0 for ; Mon, 11 Jul 2022 18:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5FnGqBtG/hvZkeipidbFnHIGC/AKE2ThXB60YFMOud8=; b=Mdlur6hrJe7M2FAq3MvBfwC/AoT9N07gNypU9DbCRrmIceaqsgntkwsNnylg1q391x fD4dE4hwSVm0gghDy0cER2Oj8fg/zMngGjDCuqEDIj3mYwErLONGYLh9o5YHy2MuIc/n CecuVMY7qmU190feDaVutEEBrQmyWBNBiZg6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5FnGqBtG/hvZkeipidbFnHIGC/AKE2ThXB60YFMOud8=; b=zFMnW+MDAk3YAzMkr7ZT2VXeLZDxwp8wLIgoEVhQyufaMu7MM/nbfH2ECy8+04n9oZ ZC+1Aq1yC8Brf/NbvwHh0xfYugzVA5YnukL9GInH2fWG08Se6hojUw9H+hDzA3fX824S LXDl4LBq/WZXVIsBPk8nCGTyWcec4qnn/RYsTwEUyWfI2aQ7dBO4srdIYiAbBBRl2xVm A7CpgnGkKTPC2Ig/8lK6b1F9oVchI4RM0oB+3EVrLHI00evwoH5z2IjEuhpLw21mc72N oo2OwDY23ZwgP3AZ/WeV5lhvFDrSSB9Y9Z9gJZavKKmkVBBTz623D0fABCBHgokZITTs WFLg== X-Gm-Message-State: AJIora8kJLdiioX5J8rMwnYFBDFrImLL1aA0eFs8Sb7k6aiRwqgKCuGx TiIBRLawiQu1LPu9rmn9jNyxtIlFwJO0LxUG X-Google-Smtp-Source: AGRyM1ujmWLN2DY0N+TdNGX0XkslGiZI3Yso0yeKv6TG3/2wAiyYxDAIGcuiGpN1nUpZGc2UXuzg7w== X-Received: by 2002:a05:6000:186a:b0:21d:ae19:b737 with SMTP id d10-20020a056000186a00b0021dae19b737mr2415737wri.317.1657587880983; Mon, 11 Jul 2022 18:04:40 -0700 (PDT) Received: from sjg1.roam.corp.google.com (host-92-0-109-232.as13285.net. [92.0.109.232]) by smtp.gmail.com with ESMTPSA id p12-20020a5d48cc000000b0021d9d13bf6csm5541152wrs.97.2022.07.11.18.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 18:04:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH 08/19] buildman: Convert camel case in board.py Date: Mon, 11 Jul 2022 19:04:02 -0600 Message-Id: <20220712010413.331984-9-sjg@chromium.org> X-Mailer: git-send-email 2.37.0.144.g8ac04bfd2-goog In-Reply-To: <20220712010413.331984-1-sjg@chromium.org> References: <20220712010413.331984-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass --- tools/buildman/board.py | 38 ++++++++++++++++++------------------- tools/buildman/control.py | 12 ++++++------ tools/buildman/func_test.py | 10 +++++----- tools/buildman/test.py | 24 +++++++++++------------ 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/tools/buildman/board.py b/tools/buildman/board.py index 8de71e487ee..ebb9d6f67dc 100644 --- a/tools/buildman/board.py +++ b/tools/buildman/board.py @@ -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 diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c4dfc2af571..a5c1c2e51c6 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -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 diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 23627f3b0f2..6806ea7fbe6 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -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)) diff --git a/tools/buildman/test.py b/tools/buildman/test.py index 6c09cb7fad5..d7306fb4dfa 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -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): -- 2.37.0.144.g8ac04bfd2-goog