desktop-notifier 4.0.0.dev0__tar.gz → 5.0.0__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 (26) hide show
  1. {desktop_notifier-4.0.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-5.0.0}/PKG-INFO +11 -11
  2. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/README.md +7 -7
  3. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/pyproject.toml +4 -4
  4. desktop_notifier-5.0.0/src/desktop_notifier/__init__.py +40 -0
  5. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/base.py +252 -24
  6. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/dbus.py +91 -20
  7. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/dummy.py +8 -3
  8. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/macos.py +83 -72
  9. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/macos_support.py +14 -11
  10. desktop_notifier-5.0.0/src/desktop_notifier/main.py +296 -0
  11. desktop_notifier-5.0.0/src/desktop_notifier/sync.py +137 -0
  12. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/winrt.py +45 -13
  13. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0/src/desktop_notifier.egg-info}/PKG-INFO +11 -11
  14. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier.egg-info/SOURCES.txt +3 -1
  15. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier.egg-info/requires.txt +3 -3
  16. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/tests/test_api.py +77 -23
  17. desktop_notifier-5.0.0/tests/test_sync_api.py +66 -0
  18. desktop_notifier-4.0.0.dev0/src/desktop_notifier/__init__.py +0 -18
  19. desktop_notifier-4.0.0.dev0/src/desktop_notifier/main.py +0 -358
  20. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/LICENSE +0 -0
  21. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/setup.cfg +0 -0
  22. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/py.typed +0 -0
  23. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/resources/__init__.py +0 -0
  24. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier/resources/python.png +0 -0
  25. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier.egg-info/dependency_links.txt +0 -0
  26. {desktop_notifier-4.0.0.dev0 → desktop_notifier-5.0.0}/src/desktop_notifier.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: desktop-notifier
3
- Version: 4.0.0.dev0
3
+ Version: 5.0.0
4
4
  Summary: Python library for cross-platform desktop notifications
5
5
  Author-email: Sam Schott <sam.schott@outlook.com>
6
6
  License: MIT
@@ -39,10 +39,10 @@ Requires-Dist: pytest; extra == "dev"
39
39
  Requires-Dist: pytest-asyncio; extra == "dev"
40
40
  Requires-Dist: pytest-cov; extra == "dev"
41
41
  Provides-Extra: docs
42
- Requires-Dist: furo==2024.4.27; extra == "docs"
42
+ Requires-Dist: furo==2024.5.6; extra == "docs"
43
43
  Requires-Dist: sphinx==7.3.7; extra == "docs"
44
- Requires-Dist: sphinx-autoapi==3.0.0; extra == "docs"
45
- Requires-Dist: sphinx-mdinclude==0.6.0; extra == "docs"
44
+ Requires-Dist: sphinx-autoapi==3.1.2; extra == "docs"
45
+ Requires-Dist: sphinx-mdinclude==0.6.1; extra == "docs"
46
46
 
47
47
  [![PyPi Release](https://img.shields.io/pypi/v/desktop-notifier.svg)](https://pypi.org/project/desktop-notifier/)
48
48
  [![Pyversions](https://img.shields.io/pypi/pyversions/desktop-notifier.svg)](https://pypi.org/pypi/desktop-notifier/)
@@ -64,7 +64,7 @@ Currently supported platforms are:
64
64
  `desktop-notifier` aims to be a good citizen of the platforms which it supports. It
65
65
  therefore stays within the limits of the native platform APIs and does not try to work
66
66
  around limitations which are often deliberate UI choices. For example, on macOS and
67
- iOS, it is not possible to change the app icon which is shown on notifications. There
67
+ iOS, it is not possible to change the app icon which is shown on notifications. There
68
68
  are possible workarounds - that would likely be rejected by an App Store review - and
69
69
  desktop-notifier deliberately stays away from those.
70
70
 
@@ -109,7 +109,7 @@ notifier = DesktopNotifier()
109
109
 
110
110
  async def main():
111
111
  n = await notifier.send(title="Hello world!", message="Sent from Python")
112
-
112
+
113
113
  await asyncio.sleep(5) # wait a bit before clearing notification
114
114
 
115
115
  await notifier.clear(n) # removes the notification
@@ -118,7 +118,7 @@ async def main():
118
118
  asyncio.run(main())
119
119
  ```
120
120
 
121
- For convenience, there is also a synchronous method ``send_sync()`` to send
121
+ For convenience, there is also a synchronous method ``send_sync()`` to send
122
122
  notifications without manually starting an asyncio event loop:
123
123
 
124
124
  ```Python
@@ -133,7 +133,7 @@ the top of the page:
133
133
 
134
134
  ```Python
135
135
  import asyncio
136
- from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField
136
+ from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField, DEFAULT_SOUND
137
137
 
138
138
  notifier = DesktopNotifier()
139
139
 
@@ -154,9 +154,9 @@ async def main():
154
154
  ),
155
155
  on_clicked=lambda: print("Notification clicked"),
156
156
  on_dismissed=lambda: print("Notification dismissed"),
157
- sound=True,
157
+ sound_file=DEFAULT_SOUND,
158
158
  )
159
-
159
+
160
160
 
161
161
  loop = asyncio.get_event_loop()
162
162
  loop.create_task(main())
@@ -216,7 +216,7 @@ Note that the installer from [python.org](https://python.org) provides a properl
216
216
  Python framework but **homebrew does not** (manually signing the executable installed
217
217
  by homebrew *should* work as well).
218
218
 
219
- If you freeze your code with PyInstaller or a similar packaging solution, you must sign
219
+ If you freeze your code with PyInstaller or a similar packaging solution, you must sign
220
220
  the resulting app bundle for notifications to work. An ad-hoc signature will be
221
221
  sufficient but signing with an Apple developer certificate is recommended for
222
222
  distribution and may be required on future releases of macOS.
@@ -18,7 +18,7 @@ Currently supported platforms are:
18
18
  `desktop-notifier` aims to be a good citizen of the platforms which it supports. It
19
19
  therefore stays within the limits of the native platform APIs and does not try to work
20
20
  around limitations which are often deliberate UI choices. For example, on macOS and
21
- iOS, it is not possible to change the app icon which is shown on notifications. There
21
+ iOS, it is not possible to change the app icon which is shown on notifications. There
22
22
  are possible workarounds - that would likely be rejected by an App Store review - and
23
23
  desktop-notifier deliberately stays away from those.
24
24
 
@@ -63,7 +63,7 @@ notifier = DesktopNotifier()
63
63
 
64
64
  async def main():
65
65
  n = await notifier.send(title="Hello world!", message="Sent from Python")
66
-
66
+
67
67
  await asyncio.sleep(5) # wait a bit before clearing notification
68
68
 
69
69
  await notifier.clear(n) # removes the notification
@@ -72,7 +72,7 @@ async def main():
72
72
  asyncio.run(main())
73
73
  ```
74
74
 
75
- For convenience, there is also a synchronous method ``send_sync()`` to send
75
+ For convenience, there is also a synchronous method ``send_sync()`` to send
76
76
  notifications without manually starting an asyncio event loop:
77
77
 
78
78
  ```Python
@@ -87,7 +87,7 @@ the top of the page:
87
87
 
88
88
  ```Python
89
89
  import asyncio
90
- from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField
90
+ from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField, DEFAULT_SOUND
91
91
 
92
92
  notifier = DesktopNotifier()
93
93
 
@@ -108,9 +108,9 @@ async def main():
108
108
  ),
109
109
  on_clicked=lambda: print("Notification clicked"),
110
110
  on_dismissed=lambda: print("Notification dismissed"),
111
- sound=True,
111
+ sound_file=DEFAULT_SOUND,
112
112
  )
113
-
113
+
114
114
 
115
115
  loop = asyncio.get_event_loop()
116
116
  loop.create_task(main())
@@ -170,7 +170,7 @@ Note that the installer from [python.org](https://python.org) provides a properl
170
170
  Python framework but **homebrew does not** (manually signing the executable installed
171
171
  by homebrew *should* work as well).
172
172
 
173
- If you freeze your code with PyInstaller or a similar packaging solution, you must sign
173
+ If you freeze your code with PyInstaller or a similar packaging solution, you must sign
174
174
  the resulting app bundle for notifications to work. An ad-hoc signature will be
175
175
  sufficient but signing with an Apple developer certificate is recommended for
176
176
  distribution and may be required on future releases of macOS.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "desktop-notifier"
7
- version = "4.0.0.dev0"
7
+ version = "5.0.0"
8
8
  authors = [{name = "Sam Schott", email = "sam.schott@outlook.com"}]
9
9
  license = {text = "MIT"}
10
10
  description = "Python library for cross-platform desktop notifications"
@@ -54,10 +54,10 @@ dev = [
54
54
  "pytest-cov",
55
55
  ]
56
56
  docs = [
57
- "furo==2024.4.27",
57
+ "furo==2024.5.6",
58
58
  "sphinx==7.3.7",
59
- "sphinx-autoapi==3.0.0",
60
- "sphinx-mdinclude==0.6.0",
59
+ "sphinx-autoapi==3.1.2",
60
+ "sphinx-mdinclude==0.6.1",
61
61
  ]
62
62
 
63
63
  [tool.setuptools.package-data]
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Desktop notifications for Windows, Linux, macOS, iOS and iPadOS.
4
+ """
5
+ from .main import (
6
+ DesktopNotifier,
7
+ Button,
8
+ ReplyField,
9
+ Notification,
10
+ Urgency,
11
+ Capability,
12
+ Icon,
13
+ Sound,
14
+ Attachment,
15
+ DEFAULT_SOUND,
16
+ DEFAULT_ICON,
17
+ )
18
+ from .sync import DesktopNotifierSync
19
+
20
+ __version__ = "5.0.0"
21
+ __author__ = "Sam Schott"
22
+ __url__ = "https://github.com/samschott/desktop-notifier"
23
+
24
+ __all__ = [
25
+ "__version__",
26
+ "__author__",
27
+ "__url__",
28
+ "Notification",
29
+ "Button",
30
+ "ReplyField",
31
+ "Urgency",
32
+ "Icon",
33
+ "Sound",
34
+ "Attachment",
35
+ "DesktopNotifier",
36
+ "DesktopNotifierSync",
37
+ "Capability",
38
+ "DEFAULT_SOUND",
39
+ "DEFAULT_ICON",
40
+ ]
@@ -6,9 +6,14 @@ must inherit from :class:`DesktopNotifierBase`.
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
- # system imports
10
9
  import logging
11
- from enum import Enum
10
+ from urllib.parse import urlparse, unquote
11
+ import urllib.parse
12
+ import warnings
13
+ import dataclasses
14
+ from dataclasses import dataclass
15
+ from abc import ABC, abstractmethod
16
+ from enum import Enum, auto
12
17
  from collections import deque
13
18
  from pathlib import Path
14
19
  from typing import (
@@ -21,6 +26,23 @@ from typing import (
21
26
  ContextManager,
22
27
  )
23
28
 
29
+ __all__ = [
30
+ "Capability",
31
+ "FileResource",
32
+ "Resource",
33
+ "Icon",
34
+ "Sound",
35
+ "Attachment",
36
+ "Button",
37
+ "ReplyField",
38
+ "Urgency",
39
+ "AuthorisationError",
40
+ "Notification",
41
+ "DesktopNotifierBase",
42
+ "DEFAULT_ICON",
43
+ "DEFAULT_SOUND",
44
+ ]
45
+
24
46
  try:
25
47
  from importlib.resources import as_file, files
26
48
 
@@ -33,7 +55,105 @@ except ImportError:
33
55
 
34
56
  logger = logging.getLogger(__name__)
35
57
 
36
- PYTHON_ICON_PATH = resource_path("desktop_notifier.resources", "python.png").__enter__()
58
+ python_icon_path = resource_path(
59
+ package="desktop_notifier.resources", resource="python.png"
60
+ ).__enter__()
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class FileResource:
65
+ """
66
+ A file resource represented by a URI or path
67
+
68
+ Only one of :attr:`path` or :attr:`uri` can be set.
69
+ """
70
+
71
+ path: Path | None = None
72
+ """Path to a local file"""
73
+
74
+ uri: str | None = None
75
+ """URI reference to a file"""
76
+
77
+ def __post_init__(self) -> None:
78
+ fields = dataclasses.fields(self)
79
+ set_fields = [f for f in fields if getattr(self, f.name) != f.default]
80
+ if len(set_fields) > 1:
81
+ raise RuntimeError("Only a single field can be set")
82
+ if len(set_fields) == 0:
83
+ field_names = [f.name for f in fields]
84
+ raise RuntimeError(f"Either of {field_names} must be set")
85
+
86
+ def as_uri(self) -> str:
87
+ """
88
+ Returns the represented resource as a URI string
89
+ """
90
+ if self.uri is not None:
91
+ return self.uri
92
+ if self.path is not None:
93
+ return self.path.as_uri()
94
+ raise AttributeError("No path or URI provided")
95
+
96
+ def as_path(self) -> Path:
97
+ """
98
+ Returns the represented resource as a Path
99
+
100
+ Note that any information about the URI scheme is lost on conversion.
101
+ """
102
+ if self.path is not None:
103
+ return self.path
104
+ if self.uri is not None:
105
+ parsed_uri = urlparse(self.uri)
106
+ return Path(unquote(parsed_uri.path))
107
+
108
+ raise AttributeError("No path or URI provided")
109
+
110
+
111
+ @dataclass(frozen=True)
112
+ class Resource(FileResource):
113
+ """
114
+ A resource represented by a resource name, URI or path
115
+
116
+ Only one of :attr:`path`, :attr:`uri` or :attr:`name` can be set.
117
+ """
118
+
119
+ name: str | None = None
120
+ """Name of the system resource"""
121
+
122
+ def is_named(self) -> bool:
123
+ """Returns whether the instance was initialized with ``name``"""
124
+ return self.name is not None
125
+
126
+ def is_file(self) -> bool:
127
+ """Returns whether the instance was initialized with ``path`` or ``uri``"""
128
+ return self.path is not None or self.uri is not None
129
+
130
+
131
+ @dataclass(frozen=True)
132
+ class Icon(Resource):
133
+ """An icon represented by an icon name, URI or path"""
134
+
135
+ pass
136
+
137
+
138
+ @dataclass(frozen=True)
139
+ class Attachment(FileResource):
140
+ """An attachment represented by a URI or path"""
141
+
142
+ pass
143
+
144
+
145
+ @dataclass(frozen=True)
146
+ class Sound(Resource):
147
+ """A sound represented by a sound name, URI or path"""
148
+
149
+ pass
150
+
151
+
152
+ DEFAULT_ICON = Icon(path=python_icon_path)
153
+ """Python icon"""
154
+
155
+ DEFAULT_SOUND = Sound(name="default")
156
+ """Default system notification sound"""
37
157
 
38
158
 
39
159
  class AuthorisationError(Exception):
@@ -105,18 +225,21 @@ class ReplyField:
105
225
  class Notification:
106
226
  """A desktop notification
107
227
 
228
+ Some arguments may be ignored, depending on the backend.
229
+
108
230
  :param title: Notification title.
109
231
  :param message: Notification message.
110
232
  :param urgency: Notification level: low, normal or critical.
111
- :param icon: URI for an icon to use for the notification or icon name.
233
+ :param icon: Icon to use for the notification.
112
234
  :param buttons: A list of buttons for the notification.
113
235
  :param reply_field: An optional reply field/
114
236
  :param on_clicked: Callback to call when the notification is clicked. The
115
237
  callback will be called without any arguments.
116
238
  :param on_dismissed: Callback to call when the notification is dismissed. The
117
239
  callback will be called without any arguments.
118
- :attachment: URI for an attachment to the notification.
119
- :param sound: Whether to play a sound when the notification is shown.
240
+ :param attachment: URI for an attachment to the notification.
241
+ :param sound: Sound to use for the notification. Use DEFAULT_SOUND for the
242
+ platform's default notification sound.
120
243
  :param thread: An identifier to group related notifications together.
121
244
  :param timeout: Duration for which the notification in shown.
122
245
  """
@@ -126,16 +249,48 @@ class Notification:
126
249
  title: str,
127
250
  message: str,
128
251
  urgency: Urgency = Urgency.Normal,
129
- icon: str | None = None,
252
+ icon: str | Icon | None = None,
130
253
  buttons: Sequence[Button] = (),
131
254
  reply_field: ReplyField | None = None,
132
255
  on_clicked: Callable[[], Any] | None = None,
133
256
  on_dismissed: Callable[[], Any] | None = None,
134
- attachment: str | None = None,
135
- sound: bool = False,
257
+ attachment: str | Attachment | None = None,
258
+ sound: bool | Sound | None = False,
136
259
  thread: str | None = None,
137
260
  timeout: int = -1,
138
261
  ) -> None:
262
+ if sound is True:
263
+ warnings.warn(
264
+ message="Use sound=DEFAULT_SOUND instead of sound=True. "
265
+ "Support for boolean input will be removed in a future release.",
266
+ category=DeprecationWarning,
267
+ )
268
+ sound = DEFAULT_SOUND
269
+ if sound is False:
270
+ warnings.warn(
271
+ message="Use sound=None instead of sound=False. "
272
+ "Support for boolean input will be removed in a future release.",
273
+ category=DeprecationWarning,
274
+ )
275
+ sound = None
276
+ if isinstance(icon, str):
277
+ warnings.warn(
278
+ message="Pass an Icon instance instead of a string. "
279
+ "Support for string input will be removed in a future release.",
280
+ category=DeprecationWarning,
281
+ )
282
+ if urllib.parse.urlparse(icon).hostname != "":
283
+ icon = Icon(uri=icon)
284
+ else:
285
+ icon = Icon(name=icon)
286
+ if isinstance(attachment, str):
287
+ warnings.warn(
288
+ message="Pass an Attachment instance instead of a string. "
289
+ "Support for string input will be removed in a future release.",
290
+ category=DeprecationWarning,
291
+ )
292
+ attachment = Attachment(uri=attachment)
293
+
139
294
  self._identifier = ""
140
295
  self._winrt_identifier = ""
141
296
  self._macos_identifier = ""
@@ -145,17 +300,21 @@ class Notification:
145
300
  self.message = message
146
301
  self.urgency = urgency
147
302
  self.icon = icon
148
- self.buttons = buttons
303
+ self.buttons = tuple(buttons)
149
304
  self.reply_field = reply_field
305
+ self.sound = sound
150
306
  self.on_clicked = on_clicked
151
307
  self.on_dismissed = on_dismissed
152
308
  self.attachment = attachment
153
- self.sound = sound
154
309
  self.thread = thread
155
310
  self.timeout = timeout
156
311
 
157
312
  @property
158
313
  def identifier(self) -> str:
314
+ """Unique identifier for this notification
315
+
316
+ Populated by the platform after scheduling the notification.
317
+ """
159
318
  return self._identifier
160
319
 
161
320
  @identifier.setter
@@ -163,10 +322,68 @@ class Notification:
163
322
  self._identifier = nid
164
323
 
165
324
  def __repr__(self) -> str:
166
- return f"<{self.__class__.__name__}(title='{self.title}', message='{self.message}')>"
325
+ return (
326
+ f"<{self.__class__.__name__}(identifier='{self.identifier}', "
327
+ f"title='{self.title}', message='{self.message}')>"
328
+ )
329
+
330
+
331
+ class Capability(Enum):
332
+ """Notification capabilities that can be supported by a platform"""
333
+
334
+ APP_NAME = auto()
335
+ """Supports setting a custom app name"""
336
+
337
+ TITLE = auto()
338
+ """Supports setting a notification title"""
339
+
340
+ MESSAGE = auto()
341
+ """Supports setting a notification message"""
342
+
343
+ URGENCY = auto()
344
+ """Supports different urgency levels"""
345
+
346
+ ICON = auto()
347
+ """Supports custom notification icons"""
348
+
349
+ ICON_FILE = auto()
350
+ """Supports setting a custom icon from a user-provided file"""
351
+
352
+ ICON_NAME = auto()
353
+ """Supports setting a named system icon as notification icon"""
167
354
 
355
+ BUTTONS = auto()
356
+ """Supports at least two notification buttons"""
168
357
 
169
- class DesktopNotifierBase:
358
+ REPLY_FIELD = auto()
359
+ """Supports reply fields"""
360
+
361
+ ATTACHMENT = auto()
362
+ """Supports notification attachments. Allowed file types vary by platform."""
363
+
364
+ ON_CLICKED = auto()
365
+ """Supports on-clicked callbacks"""
366
+
367
+ ON_DISMISSED = auto()
368
+ """Supports on-dismissed callbacks"""
369
+
370
+ SOUND = auto()
371
+ """Supports custom notification sounds"""
372
+
373
+ SOUND_FILE = auto()
374
+ """Supports setting a custom sound from a user-provided file"""
375
+
376
+ SOUND_NAME = auto()
377
+ """Supports setting a named system sound as notification sound"""
378
+
379
+ THREAD = auto()
380
+ """Supports grouping notifications by topic thread"""
381
+
382
+ TIMEOUT = auto()
383
+ """Supports notification timeouts"""
384
+
385
+
386
+ class DesktopNotifierBase(ABC):
170
387
  """Base class for desktop notifier implementations
171
388
 
172
389
  :param app_name: Name to identify the application in the notification center.
@@ -184,19 +401,21 @@ class DesktopNotifierBase:
184
401
  self._current_notifications: Deque[Notification] = deque([], notification_limit)
185
402
  self._notification_for_nid: Dict[str, Notification] = {}
186
403
 
404
+ @abstractmethod
187
405
  async def request_authorisation(self) -> bool:
188
406
  """
189
407
  Request authorisation to send notifications.
190
408
 
191
409
  :returns: Whether authorisation has been granted.
192
410
  """
193
- raise NotImplementedError()
411
+ ...
194
412
 
413
+ @abstractmethod
195
414
  async def has_authorisation(self) -> bool:
196
415
  """
197
416
  Returns whether we have authorisation to send notifications.
198
417
  """
199
- raise NotImplementedError()
418
+ ...
200
419
 
201
420
  async def send(self, notification: Notification) -> None:
202
421
  """
@@ -238,12 +457,12 @@ class DesktopNotifierBase:
238
457
  except ValueError:
239
458
  pass
240
459
 
241
- if notification.identifier:
242
- try:
243
- self._notification_for_nid.pop(notification.identifier)
244
- except KeyError:
245
- pass
460
+ try:
461
+ self._notification_for_nid.pop(notification.identifier)
462
+ except KeyError:
463
+ pass
246
464
 
465
+ @abstractmethod
247
466
  async def _send(
248
467
  self,
249
468
  notification: Notification,
@@ -262,7 +481,7 @@ class DesktopNotifierBase:
262
481
  :param notification_to_replace: Notification to replace, if any.
263
482
  :returns: The platform's ID for the scheduled notification.
264
483
  """
265
- raise NotImplementedError()
484
+ ...
266
485
 
267
486
  @property
268
487
  def current_notifications(self) -> List[Notification]:
@@ -280,12 +499,12 @@ class DesktopNotifierBase:
280
499
 
281
500
  :param notification: Notification to clear.
282
501
  """
283
-
284
502
  if notification.identifier:
285
503
  await self._clear(notification)
286
504
 
287
505
  self._clear_notification_from_cache(notification)
288
506
 
507
+ @abstractmethod
289
508
  async def _clear(self, notification: Notification) -> None:
290
509
  """
291
510
  Removes the given notification from the notification center. Should be
@@ -293,7 +512,7 @@ class DesktopNotifierBase:
293
512
 
294
513
  :param notification: Notification to clear.
295
514
  """
296
- raise NotImplementedError()
515
+ ...
297
516
 
298
517
  async def clear_all(self) -> None:
299
518
  """
@@ -307,9 +526,18 @@ class DesktopNotifierBase:
307
526
  self._current_notifications.clear()
308
527
  self._notification_for_nid.clear()
309
528
 
529
+ @abstractmethod
310
530
  async def _clear_all(self) -> None:
311
531
  """
312
532
  Clears all notifications from the notification center. Should be implemented by
313
533
  subclasses.
314
534
  """
315
- raise NotImplementedError()
535
+ ...
536
+
537
+ @abstractmethod
538
+ async def get_capabilities(self) -> frozenset[Capability]:
539
+ """
540
+ Returns the functionality supported by the implementation and, for Linux / dbus,
541
+ the notification server.
542
+ """
543
+ ...