From 647713050b091e55497aee5647b6d0d0abc08411 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 7 Sep 2010 14:33:53 +0100 Subject: bitbake/codeparser: Deal with functions with trailing whitespace Signed-off-by: Richard Purdie --- bitbake/lib/bb/codeparser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 951bd47b88..7d40835cb8 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py @@ -15,7 +15,14 @@ except ImportError: def check_indent(codestr): """If the code is indented, add a top level piece of code to 'remove' the indentation""" - if codestr[0] is " " or codestr[0] is " ": + i = 0 + while codestr[i] in ["\n", " ", " "]: + i = i + 1 + + if i == 0: + return codestr + + if codestr[i-1] is " " or codestr[i-1] is " ": return "if 1:\n" + codestr return codestr -- cgit v1.2.3-54-g00ecf