From 1b931d8286a0d884531dd3de26a9e3ffe4c64d22 Mon Sep 17 00:00:00 2001 From: tmaeno Date: Fri, 12 Apr 2024 15:41:50 +0200 Subject: [PATCH] added remove_rule --- PandaPkgInfo.py | 2 +- pandaserver/taskbuffer/task_split_rules.py | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/PandaPkgInfo.py b/PandaPkgInfo.py index 49a05ac56..c969e4250 100644 --- a/PandaPkgInfo.py +++ b/PandaPkgInfo.py @@ -1 +1 @@ -release_version = "0.3.2" +release_version = "0.3.3" diff --git a/pandaserver/taskbuffer/task_split_rules.py b/pandaserver/taskbuffer/task_split_rules.py index a5cbb0c0f..e04b3b443 100644 --- a/pandaserver/taskbuffer/task_split_rules.py +++ b/pandaserver/taskbuffer/task_split_rules.py @@ -168,3 +168,30 @@ def replace_rule(split_rules, rule_name, rule_value, is_sub_rule=False): tmp_str += rule_separator tmp_str += split_rule_dict[rule_name] + key_value_separator + str(rule_value) return tmp_str + + +# remove a rule +def remove_rule(split_rules, rule_token, is_sub_rule=False): + """ + Remove a rule from the split rule string + :param split_rules: comma separated string + :param rule_token: rule token + :param is_sub_rule: bool to indicate if the rule is a sub-rule + :return: string of split rules + """ + if split_rules is None: + split_rules = "" + if is_sub_rule: + rule_separator = "|" + key_value_separator = ":" + else: + rule_separator = "," + key_value_separator = "=" + tmp_str = "" + for tmp_rule in split_rules.split(rule_separator): + if tmp_rule.startswith(rule_token + key_value_separator): + continue + if tmp_str != "": + tmp_str += rule_separator + tmp_str += tmp_rule + return tmp_str