zenx 0.9.2__tar.gz → 0.9.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {zenx-0.9.2 → zenx-0.9.3}/PKG-INFO +2 -1
  2. {zenx-0.9.2 → zenx-0.9.3}/pyproject.toml +2 -1
  3. zenx-0.9.3/zenx/pipelines/discord.py +45 -0
  4. {zenx-0.9.2 → zenx-0.9.3}/zenx/settings.py +2 -0
  5. {zenx-0.9.2 → zenx-0.9.3}/zenx/spiders/base.py +1 -1
  6. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/PKG-INFO +2 -1
  7. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/SOURCES.txt +1 -0
  8. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/requires.txt +1 -0
  9. {zenx-0.9.2 → zenx-0.9.3}/setup.cfg +0 -0
  10. {zenx-0.9.2 → zenx-0.9.3}/zenx/cli.py +0 -0
  11. {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/__init__.py +0 -0
  12. {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/database.py +0 -0
  13. {zenx-0.9.2 → zenx-0.9.3}/zenx/clients/http.py +0 -0
  14. {zenx-0.9.2 → zenx-0.9.3}/zenx/debug_runner.py +0 -0
  15. {zenx-0.9.2 → zenx-0.9.3}/zenx/discovery.py +0 -0
  16. {zenx-0.9.2 → zenx-0.9.3}/zenx/engine.py +0 -0
  17. {zenx-0.9.2 → zenx-0.9.3}/zenx/exceptions.py +0 -0
  18. {zenx-0.9.2 → zenx-0.9.3}/zenx/logger.py +0 -0
  19. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/__init__.py +0 -0
  20. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/base.py +0 -0
  21. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/google_rpc.py +0 -0
  22. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/manager.py +0 -0
  23. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/preprocess.py +0 -0
  24. {zenx-0.9.2 → zenx-0.9.3}/zenx/pipelines/websocket.py +0 -0
  25. {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/__init__.py +0 -0
  26. {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/feed_pb2.py +0 -0
  27. {zenx-0.9.2 → zenx-0.9.3}/zenx/resources/proto/feed_pb2_grpc.py +0 -0
  28. {zenx-0.9.2 → zenx-0.9.3}/zenx/spiders/__init__.py +0 -0
  29. {zenx-0.9.2 → zenx-0.9.3}/zenx/utils.py +0 -0
  30. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/dependency_links.txt +0 -0
  31. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/entry_points.txt +0 -0
  32. {zenx-0.9.2 → zenx-0.9.3}/zenx.egg-info/top_level.txt +0 -0
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zenx
3
- Version: 0.9.2
3
+ Version: 0.9.3
4
4
  Summary: mini-framework
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: curl-cffi>=0.12.0
7
+ Requires-Dist: httpx>=0.28.1
7
8
  Requires-Dist: parsel>=1.10.0
8
9
  Requires-Dist: pebble>=5.1.1
9
10
  Requires-Dist: pydantic>=2.11.7
@@ -1,10 +1,11 @@
1
1
  [project]
2
2
  name = "zenx"
3
- version = "0.9.2"
3
+ version = "0.9.3"
4
4
  description = "mini-framework"
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
7
7
  "curl-cffi>=0.12.0",
8
+ "httpx>=0.28.1",
8
9
  "parsel>=1.10.0",
9
10
  "pebble>=5.1.1",
10
11
  "pydantic>=2.11.7",
@@ -0,0 +1,45 @@
1
+ from httpx import AsyncClient
2
+ from typing import Dict
3
+ from structlog import BoundLogger
4
+
5
+ from zenx.pipelines.base import Pipeline
6
+ from zenx.clients.database import DBClient
7
+ from zenx.settings import Settings
8
+ from zenx.utils import log_processing_time
9
+
10
+
11
+
12
+ class SynopticDiscordPipeline(Pipeline):
13
+ name = "syncoptic_discord"
14
+ required_settings = ["SYNOPTIC_DISCORD_WEBHOOK"]
15
+
16
+
17
+ def __init__(self, logger: BoundLogger, db: DBClient, settings: Settings) -> None:
18
+ super().__init__(logger, db, settings)
19
+ self._uri = settings.SYNOPTIC_DISCORD_WEBHOOK
20
+ self._client = AsyncClient(headers={"Content-Type": "application/json"})
21
+
22
+
23
+ async def start(self) -> None:
24
+ for setting in self.required_settings:
25
+ if not getattr(self.settings, setting):
26
+ raise ValueError(f"Missing required setting: {setting}")
27
+
28
+
29
+ @log_processing_time
30
+ async def process_item(self, item: Dict, spider: str) -> Dict:
31
+ await self._process(item)
32
+ return item
33
+
34
+
35
+ async def _process(self, item: Dict) -> None:
36
+ try:
37
+ _item = {k: v for k, v in item.items() if not k.startswith("_")}
38
+ await self._client.post(self._uri, json=_item)
39
+ except Exception as e:
40
+ self.logger.error("processing", exception=str(e), id=item.get("_id"), pipeline=self.name)
41
+
42
+
43
+ async def close(self) -> None:
44
+ if hasattr(self, "_client") and self._client:
45
+ await self._client.aclose()
@@ -26,6 +26,8 @@ class Settings(BaseSettings):
26
26
  GRPC_ID: str | None = None
27
27
  GRPC_ID_HEADLINE: str | None = None
28
28
 
29
+ SYNOPTIC_DISCORD_WEBHOOK: str | None = None
30
+
29
31
  SYNOPTIC_API_KEY: str | None = None
30
32
  SYNOPTIC_STREAM_ID: str | None = None
31
33
 
@@ -14,7 +14,7 @@ class Spider(ABC):
14
14
  # central registry
15
15
  name: ClassVar[str]
16
16
  _registry: ClassVar[Dict[str, Type[Spider]]] = {}
17
- pipelines: ClassVar[List[Literal["preprocess","synoptic_websocket","synoptic_grpc"]]]
17
+ pipelines: ClassVar[List[Literal["preprocess","synoptic_websocket","synoptic_grpc","synoptic_discord"]]]
18
18
  client_name: ClassVar[Literal["curl_cffi"]] = "curl_cffi"
19
19
 
20
20
 
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zenx
3
- Version: 0.9.2
3
+ Version: 0.9.3
4
4
  Summary: mini-framework
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: curl-cffi>=0.12.0
7
+ Requires-Dist: httpx>=0.28.1
7
8
  Requires-Dist: parsel>=1.10.0
8
9
  Requires-Dist: pebble>=5.1.1
9
10
  Requires-Dist: pydantic>=2.11.7
@@ -18,6 +18,7 @@ zenx/clients/database.py
18
18
  zenx/clients/http.py
19
19
  zenx/pipelines/__init__.py
20
20
  zenx/pipelines/base.py
21
+ zenx/pipelines/discord.py
21
22
  zenx/pipelines/google_rpc.py
22
23
  zenx/pipelines/manager.py
23
24
  zenx/pipelines/preprocess.py
@@ -1,4 +1,5 @@
1
1
  curl-cffi>=0.12.0
2
+ httpx>=0.28.1
2
3
  parsel>=1.10.0
3
4
  pebble>=5.1.1
4
5
  pydantic>=2.11.7
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes