[gnome-continuous-yocto/gnomeostree-3.28-rocko: 566/8267] lib/oe/recipeutils: patch_recipe_lines: allow omitting trailing newlines
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 566/8267] lib/oe/recipeutils: patch_recipe_lines: allow omitting trailing newlines
- Date: Sat, 16 Dec 2017 20:36:23 +0000 (UTC)
commit 9f56b98c27cc33fab3420e7a6e2cfb0626dc0976
Author: Paul Eggleton <paul eggleton linux intel com>
Date: Mon May 30 10:20:57 2016 +1200
lib/oe/recipeutils: patch_recipe_lines: allow omitting trailing newlines
This function was assuming that what you wanted was that output lines
had trailing newline characters. If you're just outputting each line
verbatim to a text file then that's fine, but sometimes you start with
the assumption that the lines don't have trailing newlines; thus we
shouldn't allow for the possibility that the caller doesn't want them
and add a parameter to control it.
(From OE-Core rev: fb2bb509ff5c7bd71b41a1dcba3b1bff1d18cf5d)
Signed-off-by: Paul Eggleton <paul eggleton linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
meta/lib/oe/recipeutils.py | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index ef82755..b9f6ada 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -158,7 +158,7 @@ def split_var_value(value, assignment=True):
return outlist
-def patch_recipe_lines(fromlines, values):
+def patch_recipe_lines(fromlines, values, trailing_newline=True):
"""Update or insert variable values into lines from a recipe.
Note that some manual inspection/intervention may be required
since this cannot handle all situations.
@@ -166,6 +166,11 @@ def patch_recipe_lines(fromlines, values):
import bb.utils
+ if trailing_newline:
+ newline = '\n'
+ else:
+ newline = ''
+
recipe_progression_res = []
recipe_progression_restrs = []
for item in recipe_progression:
@@ -196,7 +201,7 @@ def patch_recipe_lines(fromlines, values):
def outputvalue(name, lines, rewindcomments=False):
if values[name] is None:
return
- rawtext = '%s = "%s"\n' % (name, values[name])
+ rawtext = '%s = "%s"%s' % (name, values[name], newline)
addlines = []
if name in nowrap_vars:
addlines.append(rawtext)
@@ -204,19 +209,19 @@ def patch_recipe_lines(fromlines, values):
splitvalue = split_var_value(values[name], assignment=False)
if len(splitvalue) > 1:
linesplit = ' \\\n' + (' ' * (len(name) + 4))
- addlines.append('%s = "%s%s"\n' % (name, linesplit.join(splitvalue), linesplit))
+ addlines.append('%s = "%s%s"%s' % (name, linesplit.join(splitvalue), linesplit, newline))
else:
addlines.append(rawtext)
else:
wrapped = textwrap.wrap(rawtext)
for wrapline in wrapped[:-1]:
- addlines.append('%s \\\n' % wrapline)
- addlines.append('%s\n' % wrapped[-1])
+ addlines.append('%s \\%s' % (wrapline, newline))
+ addlines.append('%s%s' % (wrapped[-1], newline))
if rewindcomments:
# Ensure we insert the lines before any leading comments
# (that we'd want to ensure remain leading the next value)
for i, ln in reversed(list(enumerate(lines))):
- if ln[0] != '#':
+ if not ln.startswith('#'):
lines[i+1:i+1] = addlines
break
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]