Skip to content

Commit 93fea5f

Browse files
committed
Rename the parameter title to summary
1 parent 34fcdc9 commit 93fea5f

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

notify/linux/notify.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@ class LinuxNotification:
2323
image: The icon filename or icon theme-compliant name
2424
"""
2525

26-
def __call__(
27-
self,
28-
message,
29-
title="",
30-
timeout=2000,
31-
**kwargs
32-
):
33-
app_name = kwargs.get('app_name', 'notify-send')
34-
image = kwargs.get('image', 'dialog-information')
35-
26+
def __call__(self, summary, message="", timeout=2000, **kwargs):
27+
app_name = kwargs.get("app_name", "notify-send")
28+
image = kwargs.get("image", "dialog-information")
3629
Notify.init(app_name)
37-
n = Notify.Notification.new(title, message, image)
30+
n = Notify.Notification.new(message, summary, image)
3831
n.set_timeout(timeout)
3932
n.show()
33+
return n.close()
34+

notify/notification.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
try:
2222
modulo = import_module("." + platform, __package__)
23-
except:
23+
except Exception:
2424
raise RuntimeError("Unsupported operating system: {}".format(sys.platform))
2525
else:
26-
send = getattr(modulo, "{}Notification".format(platform.title()))()
26+
caller = getattr(modulo, "{}Notification".format(platform.title()))()
2727

2828

2929
class Notification:
@@ -38,15 +38,19 @@ class Notification:
3838
**kwargs: Additional arguments (optional).
3939
"""
4040

41-
def __init__(self, message, title="", timeout=2000, **kwargs):
41+
def __init__(self, summary, message="", timeout=2000, **kwargs):
42+
self.summary = summary
4243
self.message = message
43-
self.title = title
4444
self.timeout = timeout
4545
self.kwargs = kwargs
4646

4747
def __call__(self):
48-
send(self.message, self.title, self.timeout, **self.kwargs)
48+
status = caller(
49+
self.message, self.summary, self.timeout, **self.kwargs
50+
)
51+
return status
4952

5053

51-
def notification(message, title="", timeout=2000, **kwargs):
52-
Notification(message, title, timeout, **kwargs)()
54+
def notification(summary, message="", timeout=2000, **kwargs):
55+
status = Notification(summary, message, timeout, **kwargs)()
56+
return status

notify/win32/notify.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Win32Notification:
4646
def __init__(self):
4747
self.message_map = {win32con.WM_DESTROY: self.OnDestroy}
4848

49-
def __call__(self, message="", title="", timeout=2000, **kwargs):
49+
def __call__(self, summary, message="", timeout=2000, **kwargs):
5050
tip = kwargs.get("tip", "Balloon tooltip")
5151

5252
# Register the Window class.
@@ -83,7 +83,7 @@ def __call__(self, message="", title="", timeout=2000, **kwargs):
8383
hicon = LoadImage(
8484
hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags
8585
)
86-
except:
86+
except Exception:
8787
hicon = LoadIcon(0, win32con.IDI_APPLICATION)
8888

8989
flags = NIF_ICON | NIF_MESSAGE | NIF_TIP
@@ -102,12 +102,13 @@ def __call__(self, message="", title="", timeout=2000, **kwargs):
102102
tip,
103103
message,
104104
timeout,
105-
title,
105+
summary,
106106
),
107107
)
108108
# Destroy
109109
DestroyWindow(self.hwnd)
110110
classAtom = UnregisterClass(classAtom, hinst)
111+
return True
111112

112113
def OnDestroy(self, hwnd, msg, wparam, lparam):
113114
nid = (self.hwnd, 0)

tests/test_notification.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ def test_if_notification_is_callable():
77

88

99
def test_notification_function():
10-
notification("hello world", title="optinal")
10+
status = notification("hello world", message="optinal")
11+
assert status is True
1112

1213

1314
def test_notification_class():
14-
Notification("Hello World", title="optional")()
15-
15+
status = Notification("Hello World", message="optional")()
16+
assert status is True

0 commit comments

Comments
 (0)