[PATCH i-g-t 09/10] scripts/xls_to_doc.py: better handle common attributes

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Mar 14 15:22:32 UTC 2024


Hi Mauro,
On 2024-03-14 at 11:29:18 +0100, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> 

Please describe your changes here, use also pylint,
after your patchset applied it is:

pylint scripts/xls_to_doc.py
************* Module xls_to_doc
scripts/xls_to_doc.py:422:0: W0311: Bad indentation. Found 28 spaces, expected 24 (bad-indentation)
scripts/xls_to_doc.py:27:0: R0902: Too many instance attributes (8/7) (too-many-instance-attributes)
scripts/xls_to_doc.py:145:8: C0103: Variable name "wb" doesn't conform to snake_case naming style (invalid-name)
scripts/xls_to_doc.py:302:8: C0206: Consider iterating with .items() (consider-using-dict-items)
scripts/xls_to_doc.py:366:41: W0613: Unused argument 'args' (unused-argument)

------------------------------------------------------------------
Your code has been rated at 9.84/10 (previous run: 9.82/10, +0.03)

Regards,
Kamil

> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
> ---
>  scripts/xls_to_doc.py | 27 ++++++++++++++++++++-------
>  1 file changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
> index 03feae5834d7..60f7536c8839 100755
> --- a/scripts/xls_to_doc.py
> +++ b/scripts/xls_to_doc.py
> @@ -31,9 +31,10 @@ class FillTests(TestList):
>      def __init__(self, config_path, verbose):
>          self.tests = {}
>          self.spreadsheet_data = {}
> -        self.ignore_fields = []
>          self.verbose = verbose
>  
> +        self.update_fields = []
> +
>          # Read current documentation
>          TestList.__init__(self, config_path)
>  
> @@ -78,7 +79,9 @@ class FillTests(TestList):
>              if "sublevel" in item["_properties_"]:
>                  update = item["_properties_"].get("update-from-file")
>                  if update:
> -                    self.ignore_fields.append(field)
> +                    continue
> +
> +            self.update_fields.append(field)
>  
>      def add_field(self, dic, field, value):
>          """
> @@ -276,8 +279,22 @@ class FillTests(TestList):
>  
>              test_nr = self.tests[testname]["Test"]
>  
> +            # Update common fields
>              doc_content = self.orig_doc[test_nr]
> +            fields = set(self.doc[test_nr].keys()) | set(doc_content.keys())
>  
> +            for field in sorted(fields):
> +                if field not in self.update_fields:
> +                    continue
> +
> +                value = self.doc[test_nr].get(field, "")
> +                doc_value = doc_content.get(field, "")
> +
> +                if doc_value == value:
> +                    continue
> +
> +
> +            # Update subtest fields
>              for subtest, subtest_content in sorted(self.tests[testname]["subtests"].items()):
>                  if "line" not in subtest_content:
>                      print(f"Warning: didn't find where {subtest} is documented.")
> @@ -298,11 +315,7 @@ class FillTests(TestList):
>                  fields = set(subtest_content.keys()) | set(doc_content.keys())
>  
>                  for field in sorted(fields):
> -                    if field not in self.props:
> -                        continue
> -
> -                    if args.ignore_lists:
> -                        if field in self.ignore_fields:
> +                    if field not in self.update_fields:
>                              continue
>  
>                      value = subtest_content.get(field, "")
> -- 
> 2.43.2
> 


More information about the igt-dev mailing list