From f62cea0e205c905632be3aefa82b10ef36ce8a25 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:48 -0700 Subject: dtoc: Use None to mean stdout At present dtoc uses '-' internally to mean that output should go to stdout. This is not necessary and None is more convenient. Update it. Signed-off-by: Simon Glass --- tools/dtoc/dtb_platdata.py | 10 +++++----- tools/dtoc/main.py | 2 +- tools/dtoc/test_dtoc.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 5b1bb7e..118b1a5 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -237,12 +237,12 @@ class DtbPlatdata(): file. Args: - fname (str): Filename to send output to, or '-' for stdout + fname (str): Filename to send output to, or None for stdout """ - if fname == '-': - self._outfile = sys.stdout - else: + if fname: self._outfile = open(fname, 'w') + else: + self._outfile = sys.stdout def out(self, line): """Output a string to the output file @@ -765,7 +765,7 @@ def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False, args (list): List of non-option arguments provided to the problem dtb_file (str): Filename of dtb file to process include_disabled (bool): True to include disabled nodes - output (str): Name of output file + output (str): Name of output file (None for stdout) warning_disabled (bool): True to avoid showing warnings about missing drivers drivers_additional (list): List of additional drivers to use during diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py index b94d9c3..7686c87 100755 --- a/tools/dtoc/main.py +++ b/tools/dtoc/main.py @@ -91,7 +91,7 @@ parser.add_option('-d', '--dtb-file', action='store', help='Specify the .dtb input file') parser.add_option('--include-disabled', action='store_true', help='Include disabled nodes') -parser.add_option('-o', '--output', action='store', default='-', +parser.add_option('-o', '--output', action='store', help='Select output filename') parser.add_option('-P', '--processes', type=int, help='set number of processes to use for running tests') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 4bf9044..41a10eb 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -875,7 +875,7 @@ U_BOOT_DEVICE(spl_test2) = { """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') with test_util.capture_sys_output() as _: - self.run_test(['struct'], dtb_file, '-') + self.run_test(['struct'], dtb_file, None) def test_no_command(self): """Test running dtoc without a command""" -- cgit v1.1