From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mail.openembedded.org (Postfix) with ESMTP id 81C0877541 for ; Tue, 6 Sep 2016 10:04:27 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 06 Sep 2016 03:04:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,291,1470726000"; d="scan'208";a="5042815" Received: from unknown (HELO peggleto-mobl.ger.corp.intel.com) ([10.255.181.236]) by fmsmga006.fm.intel.com with ESMTP; 06 Sep 2016 03:04:17 -0700 From: Paul Eggleton To: openembedded-core@lists.openembedded.org Date: Tue, 6 Sep 2016 22:03:30 +1200 Message-Id: <53d6cfdc12f626ee4b1a905c4d8f47eab4c7dcb7.1473155977.git.paul.eggleton@linux.intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH 9/9] recipetool: create: avoid extra blank lines in output recipe X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2016 10:04:27 -0000 If we output extra blank lines (because of some automated editing) then it makes the output recipe look a bit untidy. You could argue that we should simply have the editing code not do that, but sometimes we don't have enough context there for that to be practical. It's simple enough to just filter out the extra blank lines when writing the file, so just do it that way. Signed-off-by: Paul Eggleton --- scripts/lib/recipetool/create.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index f1ce28c..b6de999 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -715,7 +715,13 @@ def create_recipe(args): sys.stdout.write('\n'.join(outlines) + '\n') else: with open(outfile, 'w') as f: - f.write('\n'.join(outlines) + '\n') + lastline = None + for line in outlines: + if not lastline and not line: + # Skip extra blank lines + continue + f.write('%s\n' % line) + lastline = line logger.info('Recipe %s has been created; further editing may be required to make it fully functional' % outfile) if tempsrc: -- 2.5.5