From patchwork Fri Jul 19 05:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerzy Grzegorek X-Patchwork-Id: 1133902 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cNcNOb42"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45qfdR4mKKz9s4Y for ; Fri, 19 Jul 2019 15:27:05 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id AA628865DB; Fri, 19 Jul 2019 05:27:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id agqCaX2dAjwI; Fri, 19 Jul 2019 05:26:57 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C357C866A9; Fri, 19 Jul 2019 05:26:57 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id C91F01BF3F2 for ; Fri, 19 Jul 2019 05:26:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C579787626 for ; Fri, 19 Jul 2019 05:26:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TfpRzIqQzVrh for ; Fri, 19 Jul 2019 05:26:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id CD0AF84CCE for ; Fri, 19 Jul 2019 05:26:54 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id i21so29571105ljj.3 for ; Thu, 18 Jul 2019 22:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ngU5y1iNgOapo1wYv/Dl9c6ip04NIw3JRNmroW4ELBo=; b=cNcNOb42KMQtQiIR41WyJ5+UTIZMTrp3k6d2lRi7Ik2unmeo9KB3BBDintT5/4EiyW 01NEUmTtjp18B1nhT+b2lFRJoQYiM6eo+kHqSc7E3EX3zXDodWyG3W3Rb3Z0YCnWbwq9 TLTcTmOA/LXTB8vWPBu+KBKSCXKhPWsV39ImWvjNf4jk4JtCC+LfzoZBTFp7qqswXt53 e5ryA5xbsrrH4ugd5yPifKnudmsia61wKg40ELkZk1C+Dkp5u7FSgbDiE9pSsh4eBm2b +fy2NZUDCA5nx0a8ewvPvSZU5xRpZHbNIWGiUAoiTPDocJjJESfWPKJxPp6GEUgPHs3A WMAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ngU5y1iNgOapo1wYv/Dl9c6ip04NIw3JRNmroW4ELBo=; b=VQjlClSNwKgh9Uo8gAfoIyNq0/iIEHg7NBnmc3hoQVfVRs9fsyWo4mCQ82n6KkA4Am 3A+jNTsnDRGFd1taPwwJ5JIfWSbtOUb4WyU7kTedfT3XXpB78QgwsoAmSOQxrVQDS2xi LuO9WpSQ52z4wcQCUwjogohA48DfZnmqCZIchsfYuT3qNtaBF0GCC4qs1ussNaD4H+Ct bFfdz7TdHIfk4UzqbSX1Ucp8f57JBFnGTUZCuhFSZJufDLKg9KMACW8eoh+PBpeXwRPS kwzDZQcHdMKb99dYeX/nxNlrY/bFx93eKPpHNDn3E9RtixRQVMJozVIS1bjlLwSv9T4Y CoRQ== X-Gm-Message-State: APjAAAVNUzC8zpEuwtVTFUfquoSabHUyMvsGMAr70lvWUSsdiVU0+w/I EzQdWysgYuHk9NwqKhiMjSDt4LsZ X-Google-Smtp-Source: APXvYqw+HUONhi6G3XaeEUAEuty7W1HerYnkYkApVHD/B6dDT3R91ARVgL7LathMfmy8S5aYdEHZfA== X-Received: by 2002:a2e:814e:: with SMTP id t14mr27168665ljg.167.1563514012498; Thu, 18 Jul 2019 22:26:52 -0700 (PDT) Received: from localhost.localdomain (user-5-173-248-135.play-internet.pl. [5.173.248.135]) by smtp.gmail.com with ESMTPSA id m9sm4835477lfo.45.2019.07.18.22.26.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 22:26:51 -0700 (PDT) From: Jerzy Grzegorek To: buildroot@busybox.net Date: Fri, 19 Jul 2019 07:26:36 +0200 Message-Id: <20190719052636.3281-1-jerzy.m.grzegorek@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Buildroot] [PATCH v2 1/1] utils/checkpackagelib: CommentsMenusPackagesOrder: append elements to arrays if needed X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jerzy Grzegorek MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" In the future max value of level variable (index of arrays) may increase, so we have to append elements to arrays if needed. Also change order of variables. Signed-off-by: Jerzy Grzegorek --- Changes v1 -> v2: - use try/except statement instead of if one (Yann) At the beginning self.state is empty and variable level (index of arrays) is equal 0. We append elements to arrays for the first time when a line begining with "comment ", "if " or "menu ". At that moment level is equal 1 and each array should have two elements (index 0 and 1). To achieve this we can use empty arrays or arrays with an initial value (index 0). 1. Arrays with an initial value and if statement (previous version) ... if level > len(array) - 1 append elements ... 2. Empty arrays and while statement ... while level > len(array) - 1 append elements ... 3. Arrays with an initial value and try/except statement (this version) ... try: assigment staff except IndexError: append elements ... --- utils/checkpackagelib/lib_config.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py index f0edb9993d..eabb882483 100644 --- a/utils/checkpackagelib/lib_config.py +++ b/utils/checkpackagelib/lib_config.py @@ -61,9 +61,9 @@ class AttributesOrder(_CheckFunction): class CommentsMenusPackagesOrder(_CheckFunction): - print_package_warning = [True, True, True, True, True, True] - menu_of_packages = ["", "", "", "", "", ""] - package = ["", "", "", "", "", ""] + menu_of_packages = [""] + package = [""] + print_package_warning = [True] def before(self): self.state = "" @@ -87,9 +87,15 @@ class CommentsMenusPackagesOrder(_CheckFunction): self.state += "-menu" level = self.get_level() - self.package[level] = "" - self.print_package_warning[level] = True - self.menu_of_packages[level] = text[:-1] + + try: + self.menu_of_packages[level] = text[:-1] + self.package[level] = "" + self.print_package_warning[level] = True + except IndexError: + self.menu_of_packages.append(text[:-1]) + self.package.append("") + self.print_package_warning.append(True) elif text.startswith("endif") or text.startswith("endmenu"): if self.state.endswith("comment"):