meme-errors 0.1.6__tar.gz → 0.1.7__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.4
2
2
  Name: meme-errors
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Play funny meme sounds when Python errors occur!
5
5
  Home-page: https://github.com/JAY-MU-4098/meme_errors
6
6
  Author: Jay Gogra
@@ -15,7 +15,7 @@ DEFAULT_SOUNDS = {
15
15
  }
16
16
 
17
17
 
18
- def play_meme_sound(exc_type):
18
+ def play_meme_sound(exc_type, duration_ms=3000):
19
19
  # Get sound file based on exception name
20
20
  sound_file = DEFAULT_SOUNDS.get(exc_type.__name__, DEFAULT_SOUNDS["Exception"])
21
21
  try:
@@ -31,7 +31,7 @@ def play_meme_sound(exc_type):
31
31
  start_time = pygame.time.get_ticks()
32
32
  while pygame.mixer.music.get_busy():
33
33
  # Stop if it exceeds 3 seconds (3000ms)
34
- if pygame.time.get_ticks() - start_time > 3000:
34
+ if pygame.time.get_ticks() - start_time > duration_ms:
35
35
  pygame.mixer.music.stop()
36
36
  break
37
37
  pygame.time.Clock().tick(10)
@@ -51,13 +51,28 @@ sys.excepthook = meme_excepthook
51
51
 
52
52
 
53
53
  # Decorator for function-level errors
54
- def meme_sound_on_error(func):
54
+ def meme_sound_on_error(func=None, *, duration_ms=3000):
55
+ """
56
+ Usage:
57
+
58
+ @meme_sound_on_error
59
+ def func(): ...
60
+
61
+ OR
62
+
63
+ @meme_sound_on_error(duration_ms=5000)
64
+ def func(): ...
65
+ """
66
+
67
+ if func is None:
68
+ return lambda f: meme_sound_on_error(f, duration_ms=duration_ms)
69
+
55
70
  def wrapper(*args, **kwargs):
56
71
  try:
57
72
  return func(*args, **kwargs)
58
73
  except Exception as e:
59
- play_meme_sound(type(e))
60
- raise e
74
+ play_meme_sound(type(e), duration_ms=duration_ms)
75
+ raise
61
76
 
62
77
  return wrapper
63
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meme-errors
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Play funny meme sounds when Python errors occur!
5
5
  Home-page: https://github.com/JAY-MU-4098/meme_errors
6
6
  Author: Jay Gogra
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = meme-errors
3
- version = 0.1.6
3
+ version = 0.1.7
4
4
  author = Jay Gogra
5
5
  author_email = pyex1.1@gmail.com
6
6
  description = Play funny meme sounds when Python errors occur!
File without changes
File without changes
File without changes