winipedia-utils 0.1.38__py3-none-any.whl → 0.1.40__py3-none-any.whl

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.
@@ -26,11 +26,10 @@ class Notification(Toast): # type: ignore[misc]
26
26
  The notification is shown in the top middle of the screen.
27
27
 
28
28
  Args:
29
- parent (QWidget): The parent widget.
30
- title (str): The title of the notification.
31
- text (str): The text of the notification.
32
- icon (ToastIcon, optional): The icon of the notification.
33
- duration (int, optional): The duration of the notification in milliseconds.
29
+ title: The title of the notification.
30
+ text: The text of the notification.
31
+ icon: The icon of the notification. Defaults to INFORMATION.
32
+ duration: The duration of the notification in milliseconds. Defaults to 10000.
34
33
  """
35
34
  super().__init__(QApplication.activeWindow())
36
35
  self.setDuration(duration)
@@ -39,17 +38,39 @@ class Notification(Toast): # type: ignore[misc]
39
38
  self.set_text(text)
40
39
 
41
40
  def set_title(self, title: str) -> None:
42
- """Set the title of the notification."""
41
+ """Set the title of the notification.
42
+
43
+ Truncates the title to fit within half the window width before setting it.
44
+
45
+ Args:
46
+ title: The title text to set.
47
+ """
43
48
  title = self.str_to_half_window_width(title)
44
49
  self.setTitle(title)
45
50
 
46
51
  def set_text(self, text: str) -> None:
47
- """Set the text of the notification."""
52
+ """Set the text of the notification.
53
+
54
+ Truncates the text to fit within half the window width before setting it.
55
+
56
+ Args:
57
+ text: The notification text to set.
58
+ """
48
59
  text = self.str_to_half_window_width(text)
49
60
  self.setText(text)
50
61
 
51
62
  def str_to_half_window_width(self, string: str) -> str:
52
- """Truncate the string to the width of the active window."""
63
+ """Truncate the string to the width of the active window.
64
+
65
+ Calculates half the width of the active window and truncates the string
66
+ to fit within that width. Falls back to 500 pixels if no active window.
67
+
68
+ Args:
69
+ string: The string to truncate.
70
+
71
+ Returns:
72
+ The truncated string that fits within half the window width.
73
+ """
53
74
  main_window = QApplication.activeWindow()
54
75
  width = main_window.width() / 2 if main_window is not None else 500
55
76
  width = int(width)
@@ -5,6 +5,7 @@ including getting and creating secrets and fernets.
5
5
  These utilities help with secure storage and retrieval of secrets.
6
6
  """
7
7
 
8
+ from base64 import b64decode, b64encode
8
9
  from collections.abc import Callable
9
10
 
10
11
  import keyring
@@ -43,9 +44,11 @@ def get_or_create_key[T](
43
44
  If it does not exist, create it with the generate_func.
44
45
  """
45
46
  service_name = f"{service_name}_{key_class.__name__}"
46
- secret = keyring.get_password(service_name, username)
47
- if secret is None:
48
- secret = generate_key_func().decode()
49
- keyring.set_password(service_name, username, secret)
50
-
51
- return key_class(secret.encode())
47
+ key = keyring.get_password(service_name, username)
48
+ if key is None:
49
+ binary_key = generate_key_func()
50
+ key = b64encode(binary_key).decode("ascii")
51
+ keyring.set_password(service_name, username, key)
52
+
53
+ binary_key = b64decode(key)
54
+ return key_class(binary_key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: winipedia-utils
3
- Version: 0.1.38
3
+ Version: 0.1.40
4
4
  Summary: A package with many utility functions
5
5
  License: MIT
6
6
  Author: Winipedia
@@ -42,20 +42,20 @@ winipedia_utils/projects/project.py,sha256=2nz1Hh51A-shjgdPCgiDw-ODrVtOtiHEHQnMP
42
42
  winipedia_utils/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
43
43
  winipedia_utils/pyside/__init__.py,sha256=knliQxknKWqxCEfxlI1K02OtbBfnTkYUZFqyYcLJNDI,52
44
44
  winipedia_utils/pyside/core/__init__.py,sha256=5VmASY9rUuZ8_PeZt8KMqnZUGxhsnE0EKbDhCIXj6Gk,57
45
- winipedia_utils/pyside/core/py_qiodevice.py,sha256=YPBeEyLJizQPdb-c45XKmmqUIKe3iFZyJQHdgp8Lqfk,3182
45
+ winipedia_utils/pyside/core/py_qiodevice.py,sha256=NE5PuvwldxoBV0XUD0vsdEqrwloU7Tujde0GvDpfZak,15789
46
46
  winipedia_utils/pyside/ui/__init__.py,sha256=h5NJ6WyveMMqxIgt0x65_mqndtncxgNmx5816KD3ubU,55
47
47
  winipedia_utils/pyside/ui/base/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
48
- winipedia_utils/pyside/ui/base/base.py,sha256=ru-CC-y9KQCHqkVHWGmV7ovIe4D149vBjpsNRPyoVAY,4146
48
+ winipedia_utils/pyside/ui/base/base.py,sha256=GthjIwaL-4n837TzK_sJNYDUzWu7Uc8z84CwGwzI_cI,5889
49
49
  winipedia_utils/pyside/ui/pages/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
50
50
  winipedia_utils/pyside/ui/pages/base/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
51
- winipedia_utils/pyside/ui/pages/base/base.py,sha256=9pt0Hsewo2q_sMu6xI5grF0dcoazRL73EiML8zKOzuE,2059
52
- winipedia_utils/pyside/ui/pages/browser.py,sha256=SzX356snnmEdzCrtIXl5mPaUkM1-_REfUurOotpVIkY,696
53
- winipedia_utils/pyside/ui/pages/player.py,sha256=PPmUNejMibKeNUm-a-1VA6i14G743YFxuxem0NZzFz4,795
51
+ winipedia_utils/pyside/ui/pages/base/base.py,sha256=-bn9rLc9hc98SZxlR7ohKZ1RU4GhccHG96462aqZ0CE,2624
52
+ winipedia_utils/pyside/ui/pages/browser.py,sha256=bAk3WYcn_4oRTQtkKIbf9_aJUZnRU9ZF9QkvhLVG7Nc,886
53
+ winipedia_utils/pyside/ui/pages/player.py,sha256=V5gfWzQSfnm-853y_psgIZCrakYedzn2TCs8HAI6IHY,2292
54
54
  winipedia_utils/pyside/ui/widgets/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
55
- winipedia_utils/pyside/ui/widgets/browser.py,sha256=5oUyQKYOYu9Zzx6adbewTtAIfnn_RVs8CLoX3rU2g28,6160
56
- winipedia_utils/pyside/ui/widgets/clickable_widget.py,sha256=nUZ7ngPFQ7utJuq9A-72TeT1wqCt_xubAxBg3xQSL64,856
57
- winipedia_utils/pyside/ui/widgets/media_player.py,sha256=jcAGeZo3ey177K2jAmqg1LOyARzn_5z26krZGKVj99c,10909
58
- winipedia_utils/pyside/ui/widgets/notification.py,sha256=_zBq9Q6SDFu3fV2AkbvyCNQmOEOy1l9mKOFAAdyteg4,1941
55
+ winipedia_utils/pyside/ui/widgets/browser.py,sha256=0wZ13XE_i2HV3fT6YZqjE7U_VcNv-jYPgifFCMvHQB0,8411
56
+ winipedia_utils/pyside/ui/widgets/clickable_widget.py,sha256=TIQsLYnzgo7hyVjq_mKxo7IoSdwb20qt6JgkJj59ZVE,1779
57
+ winipedia_utils/pyside/ui/widgets/media_player.py,sha256=rpgfR6e6Y1aYGb5l4Ioyb9OfnOTy7OifJlf3pwBa4RQ,15173
58
+ winipedia_utils/pyside/ui/widgets/notification.py,sha256=vtD3KZvQoFWYat_poDZCywsVNciScFeA8dGC1Bih2so,2532
59
59
  winipedia_utils/pyside/ui/windows/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
60
60
  winipedia_utils/pyside/ui/windows/base/__init__.py,sha256=p-maJQh7gYbXwhkqKU4wL6UNGzRAy988JP8_qLoTZDk,24
61
61
  winipedia_utils/pyside/ui/windows/base/base.py,sha256=httMbYu5QiHevD_2SrUTLnFat9nsvSNAtjTL84tRUao,1496
@@ -69,7 +69,7 @@ winipedia_utils/resources/svgs/play_icon.svg,sha256=U0RQ-S_WbcyyjeWC55BkcOtG64Gf
69
69
  winipedia_utils/resources/svgs/svg.py,sha256=-Dw6m7cm9CHT2076oZIMx7kTQw0v_ifJajXzWcpUtI0,430
70
70
  winipedia_utils/security/__init__.py,sha256=ZBa72J6MNtYumBFMoVc0ia4jsoS7oNgjaTCW0xDb6EI,53
71
71
  winipedia_utils/security/cryptography.py,sha256=zfxSDo7aE9ecmZNC6URMSEUYRpOuJ1iESg-WCSS5HP0,822
72
- winipedia_utils/security/keyring.py,sha256=6aQQAn1YH2cC33JCiTIAeeZ83ISj90ijE590eyPM1tU,1590
72
+ winipedia_utils/security/keyring.py,sha256=35bCXBmsFWyd7Ja2w9zHElayABeRZEaNXoEDDRb8ItQ,1698
73
73
  winipedia_utils/setup.py,sha256=F4NneO0wVTf7JCXLorWjTOdJl36N5fLSksoWMe4p86o,1650
74
74
  winipedia_utils/testing/__init__.py,sha256=kXhB5xw02ec5xpcW_KV--9CBKdyCjnuR-NZzAJ5tq0g,51
75
75
  winipedia_utils/testing/assertions.py,sha256=0JF4mqVTnLQ1qkAL_FuTwyN_idr00rvVlta7aDdnUXA,851
@@ -91,7 +91,7 @@ winipedia_utils/testing/tests/base/utils/utils.py,sha256=dUPDrgAxlfREQb33zz23Mfz
91
91
  winipedia_utils/testing/tests/conftest.py,sha256=8RounBlI8Jq1aLaLNpv84MW4ne8Qq0aavQextDOp5ng,920
92
92
  winipedia_utils/text/__init__.py,sha256=j2bwtK6kyeHI6SnoBjpRju0C1W2n2paXBDlNjNtaUxA,48
93
93
  winipedia_utils/text/string.py,sha256=1jbBftlgxffGgSlPnQh3aRPIr8XekEwpSenjFCW6JyM,3478
94
- winipedia_utils-0.1.38.dist-info/LICENSE,sha256=3PrKJ2CWNrnyyHaC_r0wPDSukVWgmjOxHr__eQVH7cw,1087
95
- winipedia_utils-0.1.38.dist-info/METADATA,sha256=HT7wvz4rMXg3aJcumnZQpV5j681ZAp2PzmA6cXG9jlM,12576
96
- winipedia_utils-0.1.38.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
97
- winipedia_utils-0.1.38.dist-info/RECORD,,
94
+ winipedia_utils-0.1.40.dist-info/LICENSE,sha256=3PrKJ2CWNrnyyHaC_r0wPDSukVWgmjOxHr__eQVH7cw,1087
95
+ winipedia_utils-0.1.40.dist-info/METADATA,sha256=vM1ZXS5qwL4E6__FLH-s55h95x6OhVw219Jz8p1SKus,12576
96
+ winipedia_utils-0.1.40.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
97
+ winipedia_utils-0.1.40.dist-info/RECORD,,