From 2b34dfc41f5b66ed27836b96902d6f568ed9d8c3 Mon Sep 17 00:00:00 2001 From: giorgia Date: Tue, 20 Feb 2024 11:34:56 +0100 Subject: [PATCH] added to_dict() to Results and updated setup.py --- CHANGELOG.md | 7 +++++++ routingfilter/filters/results.py | 3 +++ routingfilter/routing.py | 4 ++-- setup.py | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 589d4e0..4c3436c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.2.x +### 2.2.0 +#### Features +* Added *to_dict()* method to Results class +#### Changes +* Updated *setup.py* + ## 2.1.x ### 2.1.0 #### Features diff --git a/routingfilter/filters/results.py b/routingfilter/filters/results.py index 3d3687d..6bead98 100644 --- a/routingfilter/filters/results.py +++ b/routingfilter/filters/results.py @@ -9,3 +9,6 @@ class Results: def __init__(self, rules, output): self.rules = rules self.output = output + + def to_dict(self): + return {"output": self.output, "rules_uid": self.rules} diff --git a/routingfilter/routing.py b/routingfilter/routing.py index 503b8ee..b4fd2ff 100644 --- a/routingfilter/routing.py +++ b/routingfilter/routing.py @@ -40,7 +40,7 @@ def get_stats(self, delete: bool = False) -> dict: stats = {"streams": self.streams.get_stats(delete), "customer": self.customer.get_stats(delete)} return stats - def match(self, event: dict, type_: str = "streams", tag_field_name: str = "tags") -> List[Results] | List[None]: + def match(self, event: dict, type_: str = "streams", tag_field_name: str = "tags") -> List[Results]: """ Process a single event message and call the right stream match method. @@ -51,7 +51,7 @@ def match(self, event: dict, type_: str = "streams", tag_field_name: str = "tags :param tag_field_name: the event field to search into :type tag_field_name: str :return: A list of dictionaries containing the matched rules and the outputs - :rtype: List[dict] + :rtype: List[Results] """ # create routing_history if not exists if "certego" not in event.keys(): diff --git a/setup.py b/setup.py index 8ae8a56..571cf12 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ -from setuptools import setup +from setuptools import find_packages, setup with open("README.md", "r") as readme_file: long_description = readme_file.read() setup( name="routingfilter", - version="2.1.0", - packages=["routingfilter"], + version="2.2.0", + packages=find_packages(include=["routingfilter", "routingfilter.*"]), include_package_data=True, install_requires=["IPy~=1.1", "macaddress~=2.0.2"], url="https://github.com/certego/RoutingFilter",