@classmethod
    def factory(cls, data):
        """ Override factory in the base class to create a single instance of
        the Match class for the 'match' key. We do this as each match field
        may only exist once. Actions are trickier as keys here are not unique.
        When multiple values are present, """
        try:
            cm = CLASS_MAP[cls.__name__]
            for key in data:
                if key == 'match':
                    new_match = {}
                    for d in data[key]:
                        for k in d:
                            new_match[k] = d[k]
                    data[key] = JsonObjectFactory.create('Match', new_match)
                elif key == 'actions':
                    new_action = {}
                    keys = []
                    for d in data[key]:
                        keys.extend([(k, v) for k, v in d.items()])
                    num_keys = range(len(keys))

                    duplicates = {}

                    for i in num_keys:
                        key_name = keys[i][0]
                        if key_name in duplicates:
                            duplicates[key_name].append(i)
                        else:
                            duplicates[key_name] = [i]

                    for k, v in duplicates.items():
                        if len(v) > 1:
                            new_action[k] = [keys[i][1] for i in v]
                        else:
                            new_action[k] = keys[i][1]

                    data[key] = JsonObjectFactory.create('Action', new_action)
                elif key in cm and isinstance(data[key], list):
                    l = []
                    for d in data[key]:
                        l.append(JsonObjectFactory.create(cm[key], d))
                    data[key] = l
                elif key in cm:
                    data[key] = JsonObjectFactory.create(cm[key], data[key])
        except __HOLE__:
            pass
        return cls(**data)
dataset/ETHPy150Open dave-tucker/hp-sdn-client/hpsdnclient/datatypes.py/Flow.factory