python-ntfy 0.4.1__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-ntfy
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: An ntfy library aiming for feature completeness
5
5
  Home-page: https://github.com/MatthewCane/python-ntfy
6
6
  License: MIT
@@ -13,6 +13,7 @@ Classifier: License :: OSI Approved :: MIT License
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: mkdocstrings[python] (>=0.26.2,<0.27.0)
16
17
  Requires-Dist: requests (>=2.31.0,<3.0.0)
17
18
  Project-URL: Documentation, https://matthewcane.github.io/python-ntfy/
18
19
  Project-URL: Repository, https://github.com/MatthewCane/python-ntfy
@@ -93,7 +94,7 @@ These tools are also run in the CI pipeline and must pass before merging.
93
94
 
94
95
  ### Tests
95
96
 
96
- This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
97
+ This project is aiming for 95% code coverage. Any added features must include comprehensive tests.
97
98
 
98
99
  #### Testing Steps
99
100
 
@@ -73,7 +73,7 @@ These tools are also run in the CI pipeline and must pass before merging.
73
73
 
74
74
  ### Tests
75
75
 
76
- This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
76
+ This project is aiming for 95% code coverage. Any added features must include comprehensive tests.
77
77
 
78
78
  #### Testing Steps
79
79
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-ntfy"
3
- version = "0.4.1"
3
+ version = "0.4.3"
4
4
  description = "An ntfy library aiming for feature completeness"
5
5
  authors = ["Matthew Cane <matthew.cane0@gmail.com>"]
6
6
  readme = "README.md"
@@ -17,6 +17,7 @@ classifiers = [
17
17
  [tool.poetry.dependencies]
18
18
  python = ">=3.12, <=3.13"
19
19
  requests = "^2.31.0"
20
+ mkdocstrings = {extras = ["python"], version = "^0.26.2"}
20
21
 
21
22
  [tool.poetry.group.dev.dependencies]
22
23
  mypy = "^1.12.0"
@@ -31,6 +32,7 @@ types-pygments = "^2.18.0.20240506"
31
32
  types-colorama = "^0.4.15.20240311"
32
33
  types-requests = "^2.32.0.20241016"
33
34
  types-setuptools = "^75.2.0.20241018"
35
+ black = "^24.10.0"
34
36
 
35
37
  [build-system]
36
38
  requires = ["poetry-core"]
@@ -0,0 +1,3 @@
1
+ from ._ntfy import NtfyClient as NtfyClient
2
+
3
+ __all__ = ["NtfyClient"]
@@ -20,10 +20,13 @@ def get_cached_messages(
20
20
  A list of messages.
21
21
 
22
22
  Examples:
23
- response = client.get(since="all")
24
- response = client.get(since="all", scheduled=True)
25
- response = client.get(since="2019-01-01")
26
- response = client.get(since="2019-01-01", scheduled=True)
23
+ >>> response = client.get(since="all")
24
+
25
+ >>> response = client.get(since="all", scheduled=True)
26
+
27
+ >>> response = client.get(since="2019-01-01")
28
+
29
+ >>> response = client.get(since="2019-01-01", scheduled=True)
27
30
  """
28
31
  params = {"poll": "1"}
29
32
  if scheduled:
@@ -11,24 +11,36 @@ Typical usage example:
11
11
 
12
12
  import os
13
13
 
14
+ from ._get_functions import get_cached_messages
15
+ from ._send_functions import (
16
+ BroadcastAction,
17
+ HttpAction,
18
+ MessagePriority,
19
+ ViewAction,
20
+ send,
21
+ send_file,
22
+ )
23
+
24
+
25
+ class GetFunctionsMixin:
26
+ """Mixin for getting messages."""
27
+
28
+ get_cached_messages = get_cached_messages
14
29
 
15
- class NtfyClient:
16
- """A class for interacting with the ntfy notification service."""
17
30
 
18
- # The functions need to be imported here to:
19
- # 1. Keep the functions in a separate file
20
- # 2. Keep the docstrings working in the IDE
21
- # 3. Allow the functions to be called with self
22
- # MyPy does not like this, but it works
23
- from ._get_functions import get_cached_messages # type: ignore
24
- from ._send_functions import ( # type: ignore
25
- BroadcastAction,
26
- HttpAction,
27
- MessagePriority,
28
- ViewAction,
29
- send,
30
- send_file,
31
- )
31
+ class SendFunctionsMixin:
32
+ """Mixin for sending messages."""
33
+
34
+ send = send
35
+ send_file = send_file
36
+ BroadcastAction = BroadcastAction
37
+ HttpAction = HttpAction
38
+ MessagePriority = MessagePriority
39
+ ViewAction = ViewAction
40
+
41
+
42
+ class NtfyClient(GetFunctionsMixin, SendFunctionsMixin):
43
+ """A class for interacting with the ntfy notification service."""
32
44
 
33
45
  def __init__(
34
46
  self,
@@ -8,7 +8,16 @@ import requests
8
8
 
9
9
 
10
10
  class MessagePriority(Enum):
11
- """Ntfy message priority levels."""
11
+ """Ntfy message priority levels.
12
+
13
+ Attributes:
14
+ MIN: The minimum priority.
15
+ LOW: A low priority.
16
+ DEFAULT: The default priority.
17
+ HIGH: A high priority.
18
+ MAX: The maximum priority.
19
+ URGENT: The maximum priority.
20
+ """
12
21
 
13
22
  MIN = "1"
14
23
  LOW = "2"
@@ -19,7 +28,13 @@ class MessagePriority(Enum):
19
28
 
20
29
 
21
30
  class ActionType(Enum):
22
- """Action button types."""
31
+ """Action button types.
32
+
33
+ Attributes:
34
+ VIEW: A view action button.
35
+ BROADCAST: A broadcast action button.
36
+ HTTP: An HTTP action button.
37
+ """
23
38
 
24
39
  VIEW = "view"
25
40
  BROADCAST = "broadcast"
@@ -35,7 +50,19 @@ class Action:
35
50
 
36
51
 
37
52
  class ViewAction(Action):
53
+ """A view action button.
54
+
55
+ The view action opens a website or app when the action button is tapped.
56
+ """
57
+
38
58
  def __init__(self, label: str, url: str, clear: bool = False) -> None:
59
+ """Initialize a ViewAction.
60
+
61
+ Args:
62
+ label: Label of the action button in the notification.
63
+ url: URL to open when action is tapped.
64
+ clear: Clear notification after action button is tapped.
65
+ """
39
66
  self.action = ActionType.VIEW
40
67
  super().__init__(label=label, url=url, clear=clear)
41
68
 
@@ -52,6 +79,11 @@ class ViewAction(Action):
52
79
 
53
80
 
54
81
  class BroadcastAction(Action):
82
+ """A broadcast action button.
83
+
84
+ The broadcast action sends an Android broadcast intent when the action button is tapped.
85
+ """
86
+
55
87
  def __init__(
56
88
  self,
57
89
  label: str,
@@ -59,6 +91,14 @@ class BroadcastAction(Action):
59
91
  extras: Optional[dict[str, str]] = None,
60
92
  clear: bool = False,
61
93
  ) -> None:
94
+ """Initialize a BroadcastAction.
95
+
96
+ Args:
97
+ label: Label of the action button in the notification.
98
+ intent: Android intent name.
99
+ extras: Android intent extras.
100
+ clear: Clear notification after action button is tapped.
101
+ """
62
102
  self.action = ActionType.BROADCAST
63
103
  self.intent = intent
64
104
  self.extras = extras
@@ -85,6 +125,11 @@ class BroadcastAction(Action):
85
125
 
86
126
 
87
127
  class HttpAction(Action):
128
+ """An HTTP action button.
129
+
130
+ The http action sends a HTTP request when the action button is tapped.
131
+ """
132
+
88
133
  def __init__(
89
134
  self,
90
135
  label: str,
@@ -94,6 +139,16 @@ class HttpAction(Action):
94
139
  body: Optional[str] = None,
95
140
  clear: bool = False,
96
141
  ) -> None:
142
+ """Initialize an HttpAction.
143
+
144
+ Args:
145
+ label: Label of the action button in the notification.
146
+ url: URL to open when action is tapped.
147
+ method: HTTP method to use for request.
148
+ headers: HTTP headers to send with the request.
149
+ body: HTTP body to send with the request.
150
+ clear: Clear notification after HTTP request succeeds. If the request fails, the notification is not cleared.
151
+ """
97
152
  self.action = ActionType.HTTP
98
153
  self.method = method
99
154
  self.headers = headers
@@ -161,9 +216,11 @@ def send(
161
216
  ToDo
162
217
 
163
218
  Examples:
164
- response = client.send(message="Example message")
165
- response = client.send(message="Example message", title="Example title", priority=MessagePriority.HIGH, tags=["fire", "warning"])
166
- response = client.send(message="*Example markdown*", format_as_markdown=True)
219
+ >>> response = client.send(message="Example message")
220
+
221
+ >>> response = client.send(message="Example message", title="Example title", priority=MessagePriority.HIGH, tags=["fire", "warning"])
222
+
223
+ >>> response = client.send(message="*Example markdown*", format_as_markdown=True)
167
224
  """
168
225
  if tags is None:
169
226
  tags = []
@@ -221,7 +278,7 @@ def send_file(
221
278
  ToDo
222
279
 
223
280
  Examples:
224
- response = client.send_file(file="example.txt")
281
+ >>> response = client.send_file(file="example.txt")
225
282
  """
226
283
  if actions is None:
227
284
  actions = []
File without changes