python-ntfy 0.3.8__tar.gz → 0.4.1__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.3.8
3
+ Version: 0.4.1
4
4
  Summary: An ntfy library aiming for feature completeness
5
5
  Home-page: https://github.com/MatthewCane/python-ntfy
6
6
  License: MIT
@@ -46,7 +46,9 @@ client = NtfyClient(topic="Your topic")
46
46
  client.send("Your message here")
47
47
  ```
48
48
 
49
- See the full documentation site at [https://matthewcane.github.io/python-ntfy/](https://matthewcane.github.io/python-ntfy/).
49
+ ## Documentation
50
+
51
+ See the full documentation at [https://matthewcane.github.io/python-ntfy/](https://matthewcane.github.io/python-ntfy/).
50
52
 
51
53
  ## Supported Features
52
54
 
@@ -55,6 +57,7 @@ See the full documentation site at [https://matthewcane.github.io/python-ntfy/](
55
57
  - Custom servers
56
58
  - Sending plaintext messages
57
59
  - Sending Markdown formatted text messages
60
+ - Scheduling messages
58
61
  - Retrieving cached messages
59
62
  - Scheduled delivery
60
63
  - Tags
@@ -92,10 +95,8 @@ These tools are also run in the CI pipeline and must pass before merging.
92
95
 
93
96
  This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
94
97
 
95
- #### Setup Steps
96
-
97
- 1. Start the test docker container with `docker-compose -f tests/assets/test_containers.yml up`
98
- 2. Run the tests with `poetry run pytest --cov`
98
+ #### Testing Steps
99
99
 
100
- The tests will sent messages to the `python_ntfy_testing` topic so you will need to view the web interface and subcribe to that topic to see the test messages.
100
+ 1. Make sure you have `docker` and `docker-compose` installed
101
+ 2. Run the tests with `poetry run pytest --cov` or use the VSCode testing extension
101
102
 
@@ -26,7 +26,9 @@ client = NtfyClient(topic="Your topic")
26
26
  client.send("Your message here")
27
27
  ```
28
28
 
29
- See the full documentation site at [https://matthewcane.github.io/python-ntfy/](https://matthewcane.github.io/python-ntfy/).
29
+ ## Documentation
30
+
31
+ See the full documentation at [https://matthewcane.github.io/python-ntfy/](https://matthewcane.github.io/python-ntfy/).
30
32
 
31
33
  ## Supported Features
32
34
 
@@ -35,6 +37,7 @@ See the full documentation site at [https://matthewcane.github.io/python-ntfy/](
35
37
  - Custom servers
36
38
  - Sending plaintext messages
37
39
  - Sending Markdown formatted text messages
40
+ - Scheduling messages
38
41
  - Retrieving cached messages
39
42
  - Scheduled delivery
40
43
  - Tags
@@ -72,9 +75,7 @@ These tools are also run in the CI pipeline and must pass before merging.
72
75
 
73
76
  This project is aiming for 95% code coverage. Any added features must include comprihensive tests.
74
77
 
75
- #### Setup Steps
76
-
77
- 1. Start the test docker container with `docker-compose -f tests/assets/test_containers.yml up`
78
- 2. Run the tests with `poetry run pytest --cov`
78
+ #### Testing Steps
79
79
 
80
- The tests will sent messages to the `python_ntfy_testing` topic so you will need to view the web interface and subcribe to that topic to see the test messages.
80
+ 1. Make sure you have `docker` and `docker-compose` installed
81
+ 2. Run the tests with `poetry run pytest --cov` or use the VSCode testing extension
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-ntfy"
3
- version = "0.3.8"
3
+ version = "0.4.1"
4
4
  description = "An ntfy library aiming for feature completeness"
5
5
  authors = ["Matthew Cane <matthew.cane0@gmail.com>"]
6
6
  readme = "README.md"
@@ -69,8 +69,12 @@ ignore = [
69
69
  "ANN001", # Missing type annotation for function argument
70
70
  "ANN101", # Missing type annotation for self in method
71
71
  "S101", # Use of assert detected
72
+ "TRY003", # Use of vanilla exception messages
72
73
  ]
73
74
 
74
75
 
75
76
  [tool.ruff.lint.pydocstyle]
76
77
  convention = "google"
78
+
79
+ [tool.pytest.ini_options]
80
+ asyncio_default_fixture_loop_scope = "function"
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from datetime import datetime
2
3
  from enum import Enum
3
4
  from pathlib import Path
4
5
  from typing import Optional, Union
@@ -133,6 +134,7 @@ def send(
133
134
  priority: MessagePriority = MessagePriority.DEFAULT,
134
135
  tags: Optional[list] = None,
135
136
  actions: Optional[list[Union[ViewAction, BroadcastAction, HttpAction]]] = None,
137
+ schedule: Optional[datetime] = None,
136
138
  format_as_markdown: bool = False,
137
139
  timeout_seconds: int = 5,
138
140
  ) -> dict:
@@ -147,9 +149,10 @@ def send(
147
149
  priority: The priority of the message.
148
150
  tags: A list of tags to attach to the message. Can be an emoji short code.
149
151
  actions: A list of Actions objects to attach to the message.
152
+ schedule: The time to schedule the message to be sent.
150
153
  format_as_markdown: If true, the message will be formatted as markdown.
151
154
  additional_topics: A list of additional topics to send the message to.
152
- timeout_seconds: The number of seconds to wait before timing out.
155
+ timeout_seconds: The number of seconds to wait before timing out the reqest to the server.
153
156
 
154
157
  Returns:
155
158
  dict: The response from the server.
@@ -176,6 +179,9 @@ def send(
176
179
  if len(actions) > 0:
177
180
  headers["Actions"] = " ; ".join([action.to_header() for action in actions])
178
181
 
182
+ if schedule:
183
+ headers["Delay"] = str(int(schedule.timestamp()))
184
+
179
185
  return json.loads(
180
186
  requests.post(
181
187
  url=self.url,
@@ -194,6 +200,7 @@ def send_file(
194
200
  priority: MessagePriority = MessagePriority.DEFAULT,
195
201
  tags: Optional[list] = None,
196
202
  actions: Optional[list[Union[ViewAction, BroadcastAction, HttpAction]]] = None,
203
+ schedule: Optional[datetime] = None,
197
204
  timeout_seconds: int = 30,
198
205
  ) -> dict:
199
206
  """Sends a file to the server.
@@ -204,6 +211,7 @@ def send_file(
204
211
  priority: The priority of the message. Optional, defaults to MessagePriority.
205
212
  tags: A list of tags to attach to the message. Can be an emoji short code.
206
213
  actions: A list of ActionButton objects to attach to the message.
214
+ schedule: The time to schedule the message to be sent. Must be more than 10 seconds away and less than 3 days in the future.
207
215
  timeout_seconds: The number of seconds to wait before timing out.
208
216
 
209
217
  Returns:
@@ -228,6 +236,9 @@ def send_file(
228
236
  "Actions": " ; ".join([action.to_header() for action in actions]),
229
237
  }
230
238
 
239
+ if schedule:
240
+ headers["Delay"] = str(int(schedule.timestamp()))
241
+
231
242
  with Path(file).open("rb") as f:
232
243
  return json.loads(
233
244
  requests.post(
File without changes