public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Walter Lozano <wlozano@collabora.com>
To: Simon Glass <sjg@chromium.org>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Johan Jonker <jbx6244@gmail.com>
Subject: Re: [PATCH 2/8] dtoc: Convert to use ArgumentParser
Date: Mon, 5 Jul 2021 15:04:16 -0300	[thread overview]
Message-ID: <5d868664-2a67-73af-e79f-3f575429083e@collabora.com> (raw)
In-Reply-To: <20210704181950.1917106-3-sjg@chromium.org>

Hi Simon,

On 7/4/21 3:19 PM, Simon Glass wrote:
> Use this parser instead of OptionParser, which is deprecated.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   tools/dtoc/main.py | 51 ++++++++++++++++++++++++----------------------
>   1 file changed, 27 insertions(+), 24 deletions(-)

Reviewed-by: Walter Lozano <walter.lozano@collabora.com>

Thanks!

Walter

>
> diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
> index 93706de89bf..6f9b526bd74 100755
> --- a/tools/dtoc/main.py
> +++ b/tools/dtoc/main.py
> @@ -21,7 +21,7 @@ options. For more information about the use of this options and tool please
>   see doc/driver-model/of-plat.rst
>   """
>   
> -from optparse import OptionParser
> +from argparse import ArgumentParser
>   import os
>   import sys
>   import unittest
> @@ -51,7 +51,7 @@ def run_tests(processes, args):
>   
>       result = unittest.TestResult()
>       sys.argv = [sys.argv[0]]
> -    test_name = args and args[0] or None
> +    test_name = args.files and args.files[0] or None
>   
>       test_dtoc.setup()
>   
> @@ -66,47 +66,50 @@ def RunTestCoverage():
>       """Run the tests and check that we get 100% coverage"""
>       sys.argv = [sys.argv[0]]
>       test_util.RunTestCoverage('tools/dtoc/dtoc', '/main.py',
> -            ['tools/patman/*.py', '*/fdt*', '*test*'], options.build_dir)
> +            ['tools/patman/*.py', '*/fdt*', '*test*'], args.build_dir)
>   
>   
>   if __name__ != '__main__':
>       sys.exit(1)
>   
> -parser = OptionParser()
> -parser.add_option('-B', '--build-dir', type='string', default='b',
> +epilog = '''Generate C code from devicetree files. See of-plat.rst for details'''
> +
> +parser = ArgumentParser(epilog=epilog)
> +parser.add_argument('-B', '--build-dir', type=str, default='b',
>           help='Directory containing the build output')
> -parser.add_option('-c', '--c-output-dir', action='store',
> +parser.add_argument('-c', '--c-output-dir', action='store',
>                     help='Select output directory for C files')
> -parser.add_option('-C', '--h-output-dir', action='store',
> +parser.add_argument('-C', '--h-output-dir', action='store',
>                     help='Select output directory for H files (defaults to --c-output-di)')
> -parser.add_option('-d', '--dtb-file', action='store',
> +parser.add_argument('-d', '--dtb-file', action='store',
>                     help='Specify the .dtb input file')
> -parser.add_option('-i', '--instantiate', action='store_true', default=False,
> +parser.add_argument('-i', '--instantiate', action='store_true', default=False,
>                     help='Instantiate devices to avoid needing device_bind()')
> -parser.add_option('--include-disabled', action='store_true',
> +parser.add_argument('--include-disabled', action='store_true',
>                     help='Include disabled nodes')
> -parser.add_option('-o', '--output', action='store',
> +parser.add_argument('-o', '--output', action='store',
>                     help='Select output filename')
> -parser.add_option('-p', '--phase', type=str,
> +parser.add_argument('-p', '--phase', type=str,
>                     help='set phase of U-Boot this invocation is for (spl/tpl)')
> -parser.add_option('-P', '--processes', type=int,
> +parser.add_argument('-P', '--processes', type=int,
>                     help='set number of processes to use for running tests')
> -parser.add_option('-t', '--test', action='store_true', dest='test',
> +parser.add_argument('-t', '--test', action='store_true', dest='test',
>                     default=False, help='run tests')
> -parser.add_option('-T', '--test-coverage', action='store_true',
> -                default=False, help='run tests and check for 100% coverage')
> -(options, args) = parser.parse_args()
> +parser.add_argument('-T', '--test-coverage', action='store_true',
> +                default=False, help='run tests and check for 100%% coverage')
> +parser.add_argument('files', nargs='*')
> +args = parser.parse_args()
>   
>   # Run our meagre tests
> -if options.test:
> -    ret_code = run_tests(options.processes, args)
> +if args.test:
> +    ret_code = run_tests(args.processes, args)
>       sys.exit(ret_code)
>   
> -elif options.test_coverage:
> +elif args.test_coverage:
>       RunTestCoverage()
>   
>   else:
> -    dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
> -                           options.output,
> -                           [options.c_output_dir, options.h_output_dir],
> -                           options.phase, instantiate=options.instantiate)
> +    dtb_platdata.run_steps(args.files, args.dtb_file, args.include_disabled,
> +                           args.output,
> +                           [args.c_output_dir, args.h_output_dir],
> +                           args.phase, instantiate=args.instantiate)

  reply	other threads:[~2021-07-05 18:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-04 18:19 [PATCH 0/8] dtoc: Improvements to warnings Simon Glass
2021-07-04 18:19 ` [PATCH 1/8] dtoc: Avoid using subscripts on match objects Simon Glass
2021-07-05 18:04   ` Walter Lozano
2021-07-11 23:00     ` Simon Glass
2021-07-04 18:19 ` [PATCH 2/8] dtoc: Convert to use ArgumentParser Simon Glass
2021-07-05 18:04   ` Walter Lozano [this message]
2021-07-11 23:00     ` Simon Glass
2021-07-04 18:19 ` [PATCH 3/8] dtoc: Allow multiple warnings for a driver Simon Glass
2021-07-05 18:04   ` Walter Lozano
2021-07-11 23:00     ` Simon Glass
2021-07-12  2:23       ` Simon Glass
2021-07-04 18:19 ` [PATCH 4/8] dtoc: Correct the re_compat regular expression Simon Glass
2021-07-05 18:04   ` Walter Lozano
2021-07-11 23:00     ` Simon Glass
2021-07-04 18:19 ` [PATCH 5/8] dtoc: Add a stdout check in test_normalized_name() Simon Glass
2021-07-11 23:00   ` Simon Glass
2021-07-04 18:19 ` [PATCH 6/8] dtoc: Detect unexpected suffix on .of_match Simon Glass
2021-07-11 23:00   ` Simon Glass
2021-07-04 18:19 ` [PATCH 7/8] dtoc: Detect drivers which do not parse correctly Simon Glass
2021-07-05 18:04   ` Walter Lozano
2021-07-11 23:00     ` Simon Glass
2021-07-04 18:19 ` [PATCH 8/8] dtoc: Update documentation to cover warnings in more detail Simon Glass
2021-07-05 18:04   ` Walter Lozano
2021-07-11 23:00     ` Simon Glass
2021-07-20 18:32     ` Simon Glass

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=5d868664-2a67-73af-e79f-3f575429083e@collabora.com \
    --to=wlozano@collabora.com \
    --cc=jbx6244@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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