<commit_before>import coshsh
from coshsh.monitoringdetail import MonitoringDetail

def __detail_ident__(params={}):
    if params["monitoring_type"] == "KEYVALUES":
        return MonitoringDetailKeyvalues
    elif params["monitoring_type"] == "KEYVALUESARRAY":
        return MonitoringDetailKeyvaluesArray


class MonitoringDetailKeyvalues(coshsh.monitoringdetail.MonitoringDetail):
    """
    """
    property = "generic"
    property_type = dict

    def __init__(self, params):
        self.monitoring_type = params["monitoring_type"]
        self.dictionary = { }
        try:
            self.dictionary[params["monitoring_0"]] = params["monitoring_1"]
        except Exception:
            pass
        try:
            self.dictionary[params["monitoring_2"]] = params["monitoring_3"]
        except Exception:
            pass
        try:
            self.dictionary[params["monitoring_4"]] = params["monitoring_5"]
        except Exception:
            pass


class MonitoringDetailKeyvaluesArray(coshsh.monitoringdetail.MonitoringDetail):
    """
    KEYVALUESARRAY, role, dach
    KEYVALUESARRAY, role, master, parents, "sw1"
    KEYVALUESARRAY, role, dmz, role, prod, parents, "sw2"
    -> application.role = [dach, master, dmz, prod]
    -> application.parents = [sw1, sw2]
    """
    property = "generic"
    property_type = list

    def __init__(self, params):
        self.monitoring_type = params["monitoring_type"]
        self.dictionary = { }
        try:
            self.dictionary[params["monitoring_0"]].append(params["monitoring_1"])
        except Exception:
            self.dictionary[params["monitoring_0"]] = [params["monitoring_1"]]
        try:
            self.dictionary[params["monitoring_2"]].append(params["monitoring_3"])
        except Exception:
            self.dictionary[params["monitoring_2"]] = [params["monitoring_3"]]
        try:
            self.dictionary[params["monitoring_4"]].append(params["monitoring_5"])
        except Exception:
            self.dictionary[params["monitoring_4"]] = [params["monitoring_5"]]
<commit_msg>make detail KEYVALUESARRAY more robust<commit_after>import coshsh
from coshsh.monitoringdetail import MonitoringDetail

def __detail_ident__(params={}):
    if params["monitoring_type"] == "KEYVALUES":
        return MonitoringDetailKeyvalues
    elif params["monitoring_type"] == "KEYVALUESARRAY":
        return MonitoringDetailKeyvaluesArray


class MonitoringDetailKeyvalues(coshsh.monitoringdetail.MonitoringDetail):
    """
    """
    property = "generic"
    property_type = dict

    def __init__(self, params):
        self.monitoring_type = params["monitoring_type"]
        self.dictionary = { }
        try:
            self.dictionary[params["monitoring_0"]] = params["monitoring_1"]
        except Exception:
            pass
        try:
            self.dictionary[params["monitoring_2"]] = params["monitoring_3"]
        except Exception:
            pass
        try:
            self.dictionary[params["monitoring_4"]] = params["monitoring_5"]
        except Exception:
            pass


class MonitoringDetailKeyvaluesArray(coshsh.monitoringdetail.MonitoringDetail):
    """
    KEYVALUESARRAY, role, dach
    KEYVALUESARRAY, role, master, parents, "sw1"
    KEYVALUESARRAY, role, dmz, role, prod, parents, "sw2"
    -> application.role = [dach, master, dmz, prod]
    -> application.parents = [sw1, sw2]
    """
    property = "generic"
    property_type = list

    def __init__(self, params):
        self.monitoring_type = params["monitoring_type"]
        self.dictionary = { }
        try:
            self.dictionary[params["monitoring_0"]].append(params["monitoring_1"])
        except Exception:
            self.dictionary[params["monitoring_0"]] = [params["monitoring_1"]]
        try:
            self.dictionary[params["monitoring_2"]].append(params["monitoring_3"])
        except Exception:
            try:
                self.dictionary[params["monitoring_2"]] = [params["monitoring_3"]]
            except Exception:
                pass
        try:
            self.dictionary[params["monitoring_4"]].append(params["monitoring_5"])
        except Exception:
            try:
                self.dictionary[params["monitoring_4"]] = [params["monitoring_5"]]
            except Exception:
                pass

{'fraction_non_alphanumeric': 0.11626297577854672, 'fraction_numerical': 0.010149942329873126, 'mean_word_length': 2.8202643171806168, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5440501', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1199, 'n_words': 214}