From 0856c1ce6c4eedfdf4cc4a044a68bb033ec00dac Mon Sep 17 00:00:00 2001 From: FNTwin Date: Tue, 20 Feb 2024 10:01:02 -0700 Subject: [PATCH] Fix dummy processing --- safe/converter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/safe/converter.py b/safe/converter.py index 7611168..61ee7a9 100644 --- a/safe/converter.py +++ b/safe/converter.py @@ -332,7 +332,9 @@ def encoder( val = str(starting_num) if starting_num < 10 else f"%{starting_num}" # we cannot have anything of the form "\([@=-#-$/\]*\d+\)" attach_regexp = re.compile(r"(" + re.escape(attach) + r")") - scaffold_str = attach_regexp.sub(val, scaffold_str) + # check if we have at least 2 matches, if not, we have a dummy + n_matches= len(attach_regexp.findall(scaffold_str)) + scaffold_str = attach_regexp.sub(val, scaffold_str) if n_matches > 1 else scaffold_str.replace(attach, "*") starting_num += 1 # now we need to remove all the parenthesis around digit only number wrong_attach = re.compile(r"\(([\%\d]*)\)")