Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 06/14] scripts/test_list.py: close config file before start processing
Date: Thu, 13 Jul 2023 09:50:46 +0200	[thread overview]
Message-ID: <20230713075054.970457-7-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230713075054.970457-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

Reduce the identation level of the code which parses the config
file, as this can be done after closing the file.

This is a preparation for the next patch that will offer a different
way to pass the configuration.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 scripts/test_list.py | 114 +++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 57 deletions(-)

diff --git a/scripts/test_list.py b/scripts/test_list.py
index 565760dc0201..ac77d6523672 100644
--- a/scripts/test_list.py
+++ b/scripts/test_list.py
@@ -274,71 +274,71 @@ class TestList:
         with open(config_fname, 'r', encoding='utf8') as handle:
             self.config = json.load(handle)
 
-            self.__add_field(None, 0, 0, self.config["fields"])
+        self.__add_field(None, 0, 0, self.config["fields"])
 
-            sublevel_count = [ 0 ] * self.level_count
+        sublevel_count = [ 0 ] * self.level_count
 
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    sublevel = item["_properties_"]["sublevel"]
-                    if sublevel > sublevel_count[level - 1]:
-                        sublevel_count[level - 1] = sublevel
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                sublevel = item["_properties_"]["sublevel"]
+                if sublevel > sublevel_count[level - 1]:
+                    sublevel_count[level - 1] = sublevel
 
-                field_lc = field.lower()
-                self.field_list[field_lc] = field
-                field_plural = _plural(field_lc)
-                if field_lc != field_plural:
-                    self.field_list[field_plural] = field
+            field_lc = field.lower()
+            self.field_list[field_lc] = field
+            field_plural = _plural(field_lc)
+            if field_lc != field_plural:
+                self.field_list[field_plural] = field
 
-            if include_plan:
-                self.props["Class"] = {}
-                self.props["Class"]["_properties_"] = {}
-                self.props["Class"]["_properties_"]["level"] = 1
-                self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
+        if include_plan:
+            self.props["Class"] = {}
+            self.props["Class"]["_properties_"] = {}
+            self.props["Class"]["_properties_"]["level"] = 1
+            self.props["Class"]["_properties_"]["sublevel"] = sublevel_count[0] + 1
 
-            # Remove non-multilevel items, as we're only interested on
-            # hierarchical item levels here
-            for field, item in self.props.items():
-                if "sublevel" in item["_properties_"]:
-                    level = item["_properties_"]["level"]
-                    if sublevel_count[level - 1] == 1:
-                        del item["_properties_"]["level"]
-                        del item["_properties_"]["sublevel"]
-            del self.props["_properties_"]
+        # Remove non-multilevel items, as we're only interested on
+        # hierarchical item levels here
+        for field, item in self.props.items():
+            if "sublevel" in item["_properties_"]:
+                level = item["_properties_"]["level"]
+                if sublevel_count[level - 1] == 1:
+                    del item["_properties_"]["level"]
+                    del item["_properties_"]["sublevel"]
+        del self.props["_properties_"]
 
-            has_implemented = False
-            if not self.filenames:
-                self.filenames = []
-                exclude_files = []
-                files = self.config["files"]
-                exclude_file_glob = self.config.get("exclude_files", [])
-                for cfg_file in exclude_file_glob:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        exclude_files.append(fname)
+        has_implemented = False
+        if not self.filenames:
+            self.filenames = []
+            exclude_files = []
+            files = self.config["files"]
+            exclude_file_glob = self.config.get("exclude_files", [])
+            for cfg_file in exclude_file_glob:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    exclude_files.append(fname)
 
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        if fname in exclude_files:
-                            continue
-                        self.filenames.append(fname)
-                        has_implemented = True
-            else:
-                for cfg_file in self.filenames:
-                    if cfg_file:
-                        has_implemented = True
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    if fname in exclude_files:
+                        continue
+                    self.filenames.append(fname)
+                    has_implemented = True
+        else:
+            for cfg_file in self.filenames:
+                if cfg_file:
+                    has_implemented = True
 
-            has_planned = False
-            if include_plan and "planning_files" in self.config:
-                implemented_class = "Implemented"
-                files = self.config["planning_files"]
-                for cfg_file in files:
-                    cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
-                    for fname in glob.glob(cfg_file):
-                        self.plan_filenames.append(fname)
-                        has_planned = True
+        has_planned = False
+        if include_plan and "planning_files" in self.config:
+            implemented_class = "Implemented"
+            files = self.config["planning_files"]
+            for cfg_file in files:
+                cfg_file = os.path.realpath(os.path.dirname(config_fname)) + "/" + cfg_file
+                for fname in glob.glob(cfg_file):
+                    self.plan_filenames.append(fname)
+                    has_planned = True
 
         planned_class = None
         if has_implemented:
-- 
2.40.1

  parent reply	other threads:[~2023-07-13  7:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13  7:50 [igt-dev] [PATCH i-g-t v3 00/14] Make test_list.py more generic Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 01/14] tests/intel-ci/meson.build: Generate and store an intel-ci.testlist Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 02/14] scripts/test_list.py: make the class more generic Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 03/14] scripts/test_list.py: rename the internal summary value Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 04/14] scripts/igt_doc.py: pass a single file when checking docs Mauro Carvalho Chehab
2023-07-13 12:08   ` Kamil Konieczny
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 05/14] scripts/test_list.py: document what BAT stands for Mauro Carvalho Chehab
2023-07-13  7:50 ` Mauro Carvalho Chehab [this message]
2023-07-13 10:21   ` [igt-dev] [PATCH i-g-t v3 06/14] scripts/test_list.py: close config file before start processing Kamil Konieczny
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 07/14] scripts/test_list.py: don't rely on file name to parse config Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 08/14] scripts/test_list.py: allow passing a config dict directly Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 09/14] scripts/igt_doc.py: use field names when create a TestList instance Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 10/14] scripts/test_list.py: add a check before deleting properties Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 11/14] scripts/test_list.py: filename arguments for print_ methods are optional Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 12/14] scripts/test_list.py: skip some internal fields Mauro Carvalho Chehab
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 13/14] scripts/test_list.py: add support to return a string instead of print Mauro Carvalho Chehab
2023-07-13 12:09   ` Kamil Konieczny
2023-07-13  7:50 ` [igt-dev] [PATCH i-g-t v3 14/14] scripts/test_list.py: better handle internal fields Mauro Carvalho Chehab
2023-07-13 12:16   ` Kamil Konieczny
2023-07-13  9:10 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic Patchwork
2023-07-13 12:06 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Make test_list.py more generic (rev2) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230713075054.970457-7-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox