diff --git a/rpg/rule.py b/rpg/rule.py index aa52e4f3f89dff11a3e81a7eee2889bb6e14cff3..595d12f03e400f5db22d4592e2428561a510317f 100644 --- a/rpg/rule.py +++ b/rpg/rule.py @@ -310,19 +310,19 @@ def check_rule(exprule): core.handle_errors(to_print + "^", 2) ret = "" - # Bracket verif + # parenthesis verif if ret != "": opening = False if "(" not in clean_exprule: - core.handle_errors(", no opening bracket founded", 2, "Error") + core.handle_errors(", no opening parenthesis founded", 2, "Error") ret = "" else: for i, _ in enumerate(clean_exprule): - # Opening bracket + # Opening parenthesis if clean_exprule[i] == "(": # If we found another opening but no closing if opening: - core.handle_errors(", opening bracket founded without " + core.handle_errors(", opening parenthesis founded without " "closed one at position " + str(i + 1), 2, "Error") core.handle_errors(exprule, 2) @@ -333,13 +333,13 @@ def check_rule(exprule): ret = "" else: opening = True - # Closing bracket + # Closing parenthesis if clean_exprule[i] == ")": # Seems ok if opening: opening = False else: - core.handle_errors(", closing bracket founded without " + core.handle_errors(", closing parenthesis founded without " "opening before at position " + str(i + 1), 2, "Error") core.handle_errors(exprule, 2) @@ -349,11 +349,11 @@ def check_rule(exprule): core.handle_errors(to_print + "^", 2) ret = "" if opening is True: - core.handle_errors(", an opened bracket was never closed", 2, + core.handle_errors(", an opened parenthesis was never closed", 2, "Error") ret = "" - # comma verif: max two and in the same bracket system, and min one + # comma verif: max two and in the same parenthesis system, and min one if ret != "": if clean_exprule.count(',') > 2: core.handle_errors(", too many ',' founded", 2, "Error") @@ -362,7 +362,7 @@ def check_rule(exprule): core.handle_errors(", no ',' founded", 2, "Error") ret = "" else: - # comma always closed to a bracket + # comma always closed to a parenthesis res = re.search(r"(?<!\(),(?!\))", clean_exprule) if res: core.handle_errors(", bad comma founded at position " + @@ -373,18 +373,18 @@ def check_rule(exprule): to_print += " " core.handle_errors(to_print + "^", 2) ret = "" - # If two commas, they should be in the same bracket system + # If two commas, they should be in the same parenthesis system comma_found = False - closed_bracket = False + closed_parenthesis = False for i, _ in enumerate(clean_exprule): # First comma if clean_exprule[i] == ",": comma_found = True - # Closing bracket before the first comma + # Closing parenthesis before the first comma if comma_found and clean_exprule[i] == ")": - closed_bracket = True - # If we found another comma after the closed bracket - if comma_found and closed_bracket and clean_exprule[i] == ",": + closed_parenthesis = True + # If we found another comma after the closed parenthesis + if comma_found and closed_parenthesis and clean_exprule[i] == ",": core.handle_errors(", bad comma founded at position " + str(i + 1), 2, "Error") core.handle_errors(exprule, 2) @@ -491,7 +491,7 @@ def create_rules(all_rules): :return: rules ready to populate an :py:class:`~rpg.enzyme.Enzyme` :rtype: list(:py:class:`Rule`) - This function handle ' or ' keywords, multiple brackets, sort the + This function handle ' or ' keywords, multiple parenthesis, sort the simples rules, create sub-rules, etc. The output is ready to be used to create an :py:class:`~rpg.enzyme.Enzyme`. """ @@ -508,7 +508,8 @@ def create_rules(all_rules): for rul in tmp_rules: all_rules[rul] = tmp_cut - # handle multiple "," in one bracket so we got only ONE "," per rule + # handle multiple "," in one parenthesis + #so we got only ONE "," per rule for tmp_rule, tmp_cut in list(all_rules.items()): if tmp_rule.count(",") > 1: # Remove this complex rule @@ -551,7 +552,7 @@ def create_rules(all_rules): # Dict of pos/val of this rule dict_rule = {} for i, val in enumerate(tmp_rule): - # None empty brackets + # None empty parenthesis if val != '': dict_rule[i - ind] = val # All positions except the cleaving one