From c9fc8d30ef52b8b98c8c3ff9d37f805cbbdbcc6d Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 29 Nov 2024 09:25:01 +0100 Subject: [PATCH] Fix handling '/' in _get_num_cpu --- src/ert/config/_get_num_cpu.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ert/config/_get_num_cpu.py b/src/ert/config/_get_num_cpu.py index a072f5b34ae..90c78fe4905 100644 --- a/src/ert/config/_get_num_cpu.py +++ b/src/ert/config/_get_num_cpu.py @@ -102,8 +102,8 @@ def _get_num_cpu( """ parser = _Parser(lines_iter) + slaves_num_cpu = None try: - slaves_num_cpu = None while (words := parser.next_line(None)) is not None: if not words: continue @@ -177,6 +177,18 @@ def _split_line(line: str) -> Iterator[str]: >>> list(_split_line("3 1.0 3*4 PORO 3*INC 'HELLO WORLD ' 3*'NAME'")) ['3', '1.0', '3*4', 'PORO', '3*INC', 'HELLO WORLD ', '3*', 'NAME'] + >>> list(_split_line("KEYWORD 3.14/")) + ['KEYWORD', '3.14', '/'] + >>> list(_split_line("KEYWORD '3.14/'")) + ['KEYWORD', '3.14/'] + >>> list(_split_line("KEYWORD '3.14'/")) + ['KEYWORD', '3.14', '/'] + >>> list(_split_line("ALLPROPS/")) + ['ALLPROPS', '/'] + >>> list(_split_line("ALLPROPS -- A comment")) + ['ALLPROPS'] + >>> list(_split_line("ALLPROPS / Also a comment")) + ['ALLPROPS', '/'] """ value = "" inside_str = None @@ -199,6 +211,13 @@ def _split_line(line: str) -> Iterator[str]: # a comment value = value[0:-1] break + elif char == "/": + # End of statement + if value: + yield value + value = "" + yield "/" + break elif char.isspace(): # delimiting space if value: