From 0a2c03ff2c96e5bc796732999bc4d8e624af9991 Mon Sep 17 00:00:00 2001 From: reinaortega <miguelangel.reinaortega@etsi.org> Date: Fri, 30 Jul 2021 09:12:23 +0200 Subject: [PATCH] Bug 262 - Handling of newline character and end of text block Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org> --- src/example.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/example.py b/src/example.py index 8649606..3eac415 100644 --- a/src/example.py +++ b/src/example.py @@ -29,10 +29,17 @@ def is_body_of_example(line: str): Returns true if the line is part of the body of an example. ''' return line == "" or \ + line.startswith("\n") or \ line.startswith(".") or \ line.startswith("#") or \ line.startswith(" ") or \ bool(re.match(r'^[a-zA-Z_]*:',line)) + +def is_last_line(line: str, txt): + ''' + Returns true if it is the last line of the text. + ''' + return line == txt[len(txt)-1] def get_example_file_name(line: str): ''' @@ -88,6 +95,8 @@ def parse_all_examples(txt): new_example = "# " + filename + "\n" + linetext elif new_example != "" and is_body_of_example(linetext): new_example = new_example + "\n" + linetext + if is_last_line(line, txt): + res.append(Example(filename, new_example)) elif len(new_example) > 0: res.append(Example(filename, new_example)) new_example = "" -- GitLab