From: Simon Glass Date: Thu, 1 Jun 2017 19:38:59 -0600 Subject: [U-Boot] [PATCH v2 2/6] moveconfig: Allow reading the defconfig list from stdin In-Reply-To: <20170602013903.28731-1-sjg@chromium.org> References: <20170602013903.28731-1-sjg@chromium.org> Message-ID: <20170602013903.28731-3-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Support passes in a defconfig filename of '-' to read the list from stdin instead of from a file. Signed-off-by: Simon Glass --- Changes in v2: None tools/moveconfig.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index bfc2295238..e48b474fd9 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -298,9 +298,22 @@ def get_matched_defconfig(line): return glob.glob(pattern) + glob.glob(pattern + '_defconfig') def get_matched_defconfigs(defconfigs_file): - """Get all the defconfig files that match the patterns in a file.""" + """Get all the defconfig files that match the patterns in a file. + + Args: + defconfigs_file: File containing a list of defconfigs to process, or + '-' to read the list from stdin + + Returns: + A list of paths to defconfig files, with no duplicates + """ defconfigs = [] - for i, line in enumerate(open(defconfigs_file)): + if defconfigs_file == '-': + fd = sys.stdin + defconfigs_file = 'stdin' + else: + fd = open(defconfigs_file) + for i, line in enumerate(fd): line = line.strip() if not line: continue # skip blank lines silently @@ -1330,7 +1343,9 @@ def main(): parser.add_option('-C', '--commit', action='store_true', default=False, help='Create a git commit for the operation') parser.add_option('-d', '--defconfigs', type='string', - help='a file containing a list of defconfigs to move') + help='a file containing a list of defconfigs to move, ' + "one per line (for example 'snow_defconfig') " + "or '-' to read from stdin") parser.add_option('-n', '--dry-run', action='store_true', default=False, help='perform a trial run (show log with no changes)') parser.add_option('-e', '--exit-on-error', action='store_true', -- 2.13.0.506.g27d5fe0cd-goog