patch-chat 0.1.0__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.
Files changed (146) hide show
  1. patch/__init__.py +20 -0
  2. patch/__main__.py +4 -0
  3. patch/_version.py +24 -0
  4. patch/analytics.py +260 -0
  5. patch/args.py +955 -0
  6. patch/args_formatter.py +228 -0
  7. patch/coders/__init__.py +32 -0
  8. patch/coders/architect_coder.py +47 -0
  9. patch/coders/architect_prompts.py +40 -0
  10. patch/coders/ask_coder.py +9 -0
  11. patch/coders/ask_prompts.py +41 -0
  12. patch/coders/base_coder.py +2548 -0
  13. patch/coders/base_prompts.py +60 -0
  14. patch/coders/chat_chunks.py +64 -0
  15. patch/coders/context_coder.py +53 -0
  16. patch/coders/context_prompts.py +75 -0
  17. patch/coders/edit_apply.py +6 -0
  18. patch/coders/editblock_coder.py +620 -0
  19. patch/coders/editblock_fenced_coder.py +10 -0
  20. patch/coders/editblock_fenced_prompts.py +143 -0
  21. patch/coders/editblock_func_coder.py +141 -0
  22. patch/coders/editblock_func_prompts.py +27 -0
  23. patch/coders/editblock_prompts.py +172 -0
  24. patch/coders/editor_diff_fenced_coder.py +9 -0
  25. patch/coders/editor_diff_fenced_prompts.py +11 -0
  26. patch/coders/editor_editblock_coder.py +8 -0
  27. patch/coders/editor_editblock_prompts.py +18 -0
  28. patch/coders/editor_whole_coder.py +8 -0
  29. patch/coders/editor_whole_prompts.py +10 -0
  30. patch/coders/patch_coder.py +731 -0
  31. patch/coders/patch_prompts.py +159 -0
  32. patch/coders/search_replace.py +757 -0
  33. patch/coders/shell.py +37 -0
  34. patch/coders/single_wholefile_func_coder.py +102 -0
  35. patch/coders/single_wholefile_func_prompts.py +27 -0
  36. patch/coders/udiff_coder.py +419 -0
  37. patch/coders/udiff_prompts.py +113 -0
  38. patch/coders/udiff_simple.py +14 -0
  39. patch/coders/udiff_simple_prompts.py +25 -0
  40. patch/coders/wholefile_coder.py +144 -0
  41. patch/coders/wholefile_func_coder.py +134 -0
  42. patch/coders/wholefile_func_prompts.py +27 -0
  43. patch/coders/wholefile_prompts.py +64 -0
  44. patch/commands.py +1668 -0
  45. patch/copypaste.py +70 -0
  46. patch/deprecated.py +126 -0
  47. patch/diffs.py +128 -0
  48. patch/dump.py +29 -0
  49. patch/editor.py +147 -0
  50. patch/exceptions.py +113 -0
  51. patch/format_settings.py +47 -0
  52. patch/gui.py +545 -0
  53. patch/history.py +143 -0
  54. patch/io.py +1209 -0
  55. patch/linter.py +304 -0
  56. patch/llm.py +47 -0
  57. patch/main.py +1466 -0
  58. patch/mdstream.py +243 -0
  59. patch/models.py +1342 -0
  60. patch/onboarding.py +428 -0
  61. patch/openrouter.py +128 -0
  62. patch/prompts.py +61 -0
  63. patch/queries/tree-sitter-language-pack/README.md +7 -0
  64. patch/queries/tree-sitter-language-pack/arduino-tags.scm +5 -0
  65. patch/queries/tree-sitter-language-pack/bash-tags.scm +8 -0
  66. patch/queries/tree-sitter-language-pack/c-tags.scm +9 -0
  67. patch/queries/tree-sitter-language-pack/chatito-tags.scm +16 -0
  68. patch/queries/tree-sitter-language-pack/clojure-tags.scm +7 -0
  69. patch/queries/tree-sitter-language-pack/commonlisp-tags.scm +122 -0
  70. patch/queries/tree-sitter-language-pack/cpp-tags.scm +15 -0
  71. patch/queries/tree-sitter-language-pack/csharp-tags.scm +26 -0
  72. patch/queries/tree-sitter-language-pack/d-tags.scm +26 -0
  73. patch/queries/tree-sitter-language-pack/dart-tags.scm +92 -0
  74. patch/queries/tree-sitter-language-pack/elisp-tags.scm +5 -0
  75. patch/queries/tree-sitter-language-pack/elixir-tags.scm +54 -0
  76. patch/queries/tree-sitter-language-pack/elm-tags.scm +19 -0
  77. patch/queries/tree-sitter-language-pack/gleam-tags.scm +41 -0
  78. patch/queries/tree-sitter-language-pack/go-tags.scm +42 -0
  79. patch/queries/tree-sitter-language-pack/java-tags.scm +20 -0
  80. patch/queries/tree-sitter-language-pack/javascript-tags.scm +88 -0
  81. patch/queries/tree-sitter-language-pack/lua-tags.scm +34 -0
  82. patch/queries/tree-sitter-language-pack/matlab-tags.scm +10 -0
  83. patch/queries/tree-sitter-language-pack/ocaml-tags.scm +115 -0
  84. patch/queries/tree-sitter-language-pack/ocaml_interface-tags.scm +98 -0
  85. patch/queries/tree-sitter-language-pack/pony-tags.scm +39 -0
  86. patch/queries/tree-sitter-language-pack/properties-tags.scm +5 -0
  87. patch/queries/tree-sitter-language-pack/python-tags.scm +14 -0
  88. patch/queries/tree-sitter-language-pack/r-tags.scm +21 -0
  89. patch/queries/tree-sitter-language-pack/racket-tags.scm +12 -0
  90. patch/queries/tree-sitter-language-pack/ruby-tags.scm +64 -0
  91. patch/queries/tree-sitter-language-pack/rust-tags.scm +60 -0
  92. patch/queries/tree-sitter-language-pack/solidity-tags.scm +43 -0
  93. patch/queries/tree-sitter-language-pack/swift-tags.scm +51 -0
  94. patch/queries/tree-sitter-language-pack/udev-tags.scm +20 -0
  95. patch/queries/tree-sitter-languages/README.md +24 -0
  96. patch/queries/tree-sitter-languages/bash-tags.scm +8 -0
  97. patch/queries/tree-sitter-languages/c-tags.scm +9 -0
  98. patch/queries/tree-sitter-languages/c_sharp-tags.scm +46 -0
  99. patch/queries/tree-sitter-languages/cpp-tags.scm +15 -0
  100. patch/queries/tree-sitter-languages/dart-tags.scm +91 -0
  101. patch/queries/tree-sitter-languages/elisp-tags.scm +8 -0
  102. patch/queries/tree-sitter-languages/elixir-tags.scm +54 -0
  103. patch/queries/tree-sitter-languages/elm-tags.scm +19 -0
  104. patch/queries/tree-sitter-languages/fortran-tags.scm +15 -0
  105. patch/queries/tree-sitter-languages/go-tags.scm +30 -0
  106. patch/queries/tree-sitter-languages/haskell-tags.scm +3 -0
  107. patch/queries/tree-sitter-languages/hcl-tags.scm +77 -0
  108. patch/queries/tree-sitter-languages/java-tags.scm +20 -0
  109. patch/queries/tree-sitter-languages/javascript-tags.scm +88 -0
  110. patch/queries/tree-sitter-languages/julia-tags.scm +60 -0
  111. patch/queries/tree-sitter-languages/kotlin-tags.scm +27 -0
  112. patch/queries/tree-sitter-languages/matlab-tags.scm +10 -0
  113. patch/queries/tree-sitter-languages/ocaml-tags.scm +115 -0
  114. patch/queries/tree-sitter-languages/ocaml_interface-tags.scm +98 -0
  115. patch/queries/tree-sitter-languages/php-tags.scm +26 -0
  116. patch/queries/tree-sitter-languages/python-tags.scm +12 -0
  117. patch/queries/tree-sitter-languages/ql-tags.scm +26 -0
  118. patch/queries/tree-sitter-languages/ruby-tags.scm +64 -0
  119. patch/queries/tree-sitter-languages/rust-tags.scm +60 -0
  120. patch/queries/tree-sitter-languages/scala-tags.scm +65 -0
  121. patch/queries/tree-sitter-languages/typescript-tags.scm +41 -0
  122. patch/queries/tree-sitter-languages/zig-tags.scm +3 -0
  123. patch/reasoning_tags.py +82 -0
  124. patch/repo.py +612 -0
  125. patch/repomap.py +859 -0
  126. patch/report.py +200 -0
  127. patch/resources/__init__.py +3 -0
  128. patch/resources/model-metadata.json +715 -0
  129. patch/resources/model-settings.yml +3128 -0
  130. patch/run_cmd.py +146 -0
  131. patch/scrape.py +316 -0
  132. patch/sendchat.py +61 -0
  133. patch/special.py +203 -0
  134. patch/urls.py +17 -0
  135. patch/utils.py +365 -0
  136. patch/versioncheck.py +113 -0
  137. patch/voice.py +200 -0
  138. patch/waiting.py +222 -0
  139. patch/watch.py +318 -0
  140. patch/watch_prompts.py +12 -0
  141. patch_chat-0.1.0.dist-info/METADATA +375 -0
  142. patch_chat-0.1.0.dist-info/RECORD +146 -0
  143. patch_chat-0.1.0.dist-info/WHEEL +5 -0
  144. patch_chat-0.1.0.dist-info/entry_points.txt +2 -0
  145. patch_chat-0.1.0.dist-info/licenses/LICENSE.txt +202 -0
  146. patch_chat-0.1.0.dist-info/top_level.txt +1 -0
patch/voice.py ADDED
@@ -0,0 +1,200 @@
1
+ import math
2
+ import os
3
+ import tempfile
4
+ import time
5
+ import warnings
6
+
7
+ from prompt_toolkit.shortcuts import prompt
8
+
9
+ from patch.llm import litellm
10
+
11
+ from .dump import dump # noqa: F401
12
+
13
+ warnings.filterwarnings(
14
+ "ignore", message="Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work"
15
+ )
16
+ warnings.filterwarnings("ignore", category=SyntaxWarning)
17
+
18
+
19
+ from pydub import AudioSegment # noqa
20
+ from pydub.exceptions import CouldntDecodeError, CouldntEncodeError # noqa
21
+
22
+ try:
23
+ import soundfile as sf
24
+ except (OSError, ModuleNotFoundError):
25
+ sf = None
26
+
27
+
28
+ class SoundDeviceError(Exception):
29
+ pass
30
+
31
+
32
+ class Voice:
33
+ max_rms = 0
34
+ min_rms = 1e5
35
+ pct = 0
36
+
37
+ threshold = 0.15
38
+
39
+ def __init__(self, audio_format="wav", device_name=None):
40
+ if sf is None:
41
+ raise SoundDeviceError
42
+ try:
43
+ print("Initializing sound device...")
44
+ import sounddevice as sd
45
+
46
+ self.sd = sd
47
+
48
+ devices = sd.query_devices()
49
+
50
+ if device_name:
51
+ # Find the device with matching name
52
+ device_id = None
53
+ for i, device in enumerate(devices):
54
+ if device_name in device["name"]:
55
+ device_id = i
56
+ break
57
+ if device_id is None:
58
+ available_inputs = [d["name"] for d in devices if d["max_input_channels"] > 0]
59
+ raise ValueError(
60
+ f"Device '{device_name}' not found. Available input devices:"
61
+ f" {available_inputs}"
62
+ )
63
+
64
+ print(f"Using input device: {device_name} (ID: {device_id})")
65
+
66
+ self.device_id = device_id
67
+ else:
68
+ self.device_id = None
69
+
70
+ except (OSError, ModuleNotFoundError):
71
+ raise SoundDeviceError
72
+ if audio_format not in ["wav", "mp3", "webm"]:
73
+ raise ValueError(f"Unsupported audio format: {audio_format}")
74
+ self.audio_format = audio_format
75
+
76
+ def callback(self, indata, frames, time, status):
77
+ """This is called (from a separate thread) for each audio block."""
78
+ import numpy as np
79
+
80
+ rms = np.sqrt(np.mean(indata**2))
81
+ self.max_rms = max(self.max_rms, rms)
82
+ self.min_rms = min(self.min_rms, rms)
83
+
84
+ rng = self.max_rms - self.min_rms
85
+ if rng > 0.001:
86
+ self.pct = (rms - self.min_rms) / rng
87
+ else:
88
+ self.pct = 0.5
89
+
90
+ self.audio_file.write(indata)
91
+
92
+ def get_prompt(self):
93
+ num = 10
94
+ if math.isnan(self.pct) or self.pct < self.threshold:
95
+ cnt = 0
96
+ else:
97
+ cnt = int(self.pct * 10)
98
+
99
+ bar = "░" * cnt + "█" * (num - cnt)
100
+ bar = bar[:num]
101
+
102
+ dur = time.time() - self.start_time
103
+ return f"Recording, press ENTER when done... {dur:.1f}sec {bar}"
104
+
105
+ def record_and_transcribe(self, history=None, language=None):
106
+ try:
107
+ return self.raw_record_and_transcribe(history, language)
108
+ except KeyboardInterrupt:
109
+ return
110
+ except SoundDeviceError as e:
111
+ print(f"Error: {e}")
112
+ print("Please ensure you have a working audio input device connected and try again.")
113
+ return
114
+
115
+ def raw_record_and_transcribe(self, history, language):
116
+ temp_files = set()
117
+ temp_wav = self._temp_audio_file(".wav")
118
+ temp_files.add(temp_wav)
119
+
120
+ try:
121
+ try:
122
+ sample_rate = int(
123
+ self.sd.query_devices(self.device_id, "input")["default_samplerate"]
124
+ )
125
+ except (TypeError, ValueError):
126
+ sample_rate = 16000 # fallback to 16kHz if unable to query device
127
+ except self.sd.PortAudioError:
128
+ raise SoundDeviceError(
129
+ "No audio input device detected. Please check your audio settings and try"
130
+ " again."
131
+ )
132
+
133
+ self.start_time = time.time()
134
+
135
+ try:
136
+ with sf.SoundFile(
137
+ temp_wav, mode="w", samplerate=sample_rate, channels=1
138
+ ) as self.audio_file:
139
+ with self.sd.InputStream(
140
+ samplerate=sample_rate,
141
+ channels=1,
142
+ callback=self.callback,
143
+ device=self.device_id,
144
+ ):
145
+ prompt(self.get_prompt, refresh_interval=0.1)
146
+ except self.sd.PortAudioError as err:
147
+ raise SoundDeviceError(f"Error accessing audio input device: {err}")
148
+
149
+ use_audio_format = self.audio_format
150
+
151
+ # Check file size and offer to convert to mp3 if too large
152
+ file_size = os.path.getsize(temp_wav)
153
+ if file_size > 24.9 * 1024 * 1024 and self.audio_format == "wav":
154
+ print("\nWarning: {temp_wav} is too large, switching to mp3 format.")
155
+ use_audio_format = "mp3"
156
+
157
+ filename = temp_wav
158
+ if use_audio_format != "wav":
159
+ try:
160
+ new_filename = self._temp_audio_file(f".{use_audio_format}")
161
+ temp_files.add(new_filename)
162
+ audio = AudioSegment.from_wav(temp_wav)
163
+ audio.export(new_filename, format=use_audio_format)
164
+ filename = new_filename
165
+ except (CouldntDecodeError, CouldntEncodeError) as e:
166
+ print(f"Error converting audio: {e}")
167
+ except (OSError, FileNotFoundError) as e:
168
+ print(f"File system error during conversion: {e}")
169
+ except Exception as e:
170
+ print(f"Unexpected error during audio conversion: {e}")
171
+
172
+ with open(filename, "rb") as fh:
173
+ try:
174
+ transcript = litellm.transcription(
175
+ model="whisper-1", file=fh, prompt=history, language=language
176
+ )
177
+ except Exception as err:
178
+ print(f"Unable to transcribe {filename}: {err}")
179
+ return
180
+
181
+ return transcript.text
182
+ finally:
183
+ for filename in temp_files:
184
+ try:
185
+ os.remove(filename)
186
+ except FileNotFoundError:
187
+ pass
188
+
189
+ @staticmethod
190
+ def _temp_audio_file(suffix):
191
+ file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
192
+ file.close()
193
+ return file.name
194
+
195
+
196
+ if __name__ == "__main__":
197
+ api_key = os.getenv("OPENAI_API_KEY")
198
+ if not api_key:
199
+ raise ValueError("Please set the OPENAI_API_KEY environment variable.")
200
+ print(Voice().record_and_transcribe())
patch/waiting.py ADDED
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ Thread-based, killable spinner utility.
5
+
6
+ Use it like:
7
+
8
+ from patch.waiting import WaitingSpinner
9
+
10
+ spinner = WaitingSpinner("Waiting for LLM")
11
+ spinner.start()
12
+ ... # long task
13
+ spinner.stop()
14
+ """
15
+
16
+ import sys
17
+ import threading
18
+ import time
19
+
20
+ from rich.console import Console
21
+
22
+
23
+ class Spinner:
24
+ """
25
+ Minimal spinner that scans a single marker back and forth across a line.
26
+
27
+ The animation is pre-rendered into a list of frames. If the terminal
28
+ cannot display unicode the frames are converted to plain ASCII.
29
+ """
30
+
31
+ def __init__(self, text: str, width: int = 7):
32
+ self.text = text
33
+ self.start_time = time.time()
34
+ self.last_update = 0.0
35
+ self.visible = False
36
+ self.is_tty = sys.stdout.isatty()
37
+ self.console = Console()
38
+
39
+ # Pre-render the animation frames using pure ASCII so they will
40
+ # always display, even on very limited terminals.
41
+ ascii_frames = [
42
+ "#= ", # C1 C2 space(8)
43
+ "=# ", # C2 C1 space(8)
44
+ " =# ", # space(1) C2 C1 space(7)
45
+ " =# ", # space(2) C2 C1 space(6)
46
+ " =# ", # space(3) C2 C1 space(5)
47
+ " =# ", # space(4) C2 C1 space(4)
48
+ " =# ", # space(5) C2 C1 space(3)
49
+ " =# ", # space(6) C2 C1 space(2)
50
+ " =# ", # space(7) C2 C1 space(1)
51
+ " =#", # space(8) C2 C1
52
+ " #=", # space(8) C1 C2
53
+ " #= ", # space(7) C1 C2 space(1)
54
+ " #= ", # space(6) C1 C2 space(2)
55
+ " #= ", # space(5) C1 C2 space(3)
56
+ " #= ", # space(4) C1 C2 space(4)
57
+ " #= ", # space(3) C1 C2 space(5)
58
+ " #= ", # space(2) C1 C2 space(6)
59
+ " #= ", # space(1) C1 C2 space(7)
60
+ ]
61
+
62
+ self.unicode_palette = "░█"
63
+ xlate_from, xlate_to = ("=#", self.unicode_palette)
64
+
65
+ # If unicode is supported, swap the ASCII chars for nicer glyphs.
66
+ if self._supports_unicode():
67
+ translation_table = str.maketrans(xlate_from, xlate_to)
68
+ frames = [f.translate(translation_table) for f in ascii_frames]
69
+ self.scan_char = xlate_to[xlate_from.find("#")]
70
+ else:
71
+ frames = ascii_frames
72
+ self.scan_char = "#"
73
+
74
+ # Bounce the scanner back and forth.
75
+ self.frames = frames
76
+ self.frame_idx = 0
77
+ self.width = len(frames[0]) - 2 # number of chars between the brackets
78
+ self.animation_len = len(frames[0])
79
+ self.last_display_len = 0 # Length of the last spinner line (frame + text)
80
+
81
+ def _supports_unicode(self) -> bool:
82
+ if not self.is_tty:
83
+ return False
84
+ try:
85
+ out = self.unicode_palette
86
+ out += "\b" * len(self.unicode_palette)
87
+ out += " " * len(self.unicode_palette)
88
+ out += "\b" * len(self.unicode_palette)
89
+ sys.stdout.write(out)
90
+ sys.stdout.flush()
91
+ return True
92
+ except UnicodeEncodeError:
93
+ return False
94
+ except Exception:
95
+ return False
96
+
97
+ def _next_frame(self) -> str:
98
+ frame = self.frames[self.frame_idx]
99
+ self.frame_idx = (self.frame_idx + 1) % len(self.frames)
100
+ return frame
101
+
102
+ def step(self, text: str = None) -> None:
103
+ if text is not None:
104
+ self.text = text
105
+
106
+ if not self.is_tty:
107
+ return
108
+
109
+ now = time.time()
110
+ if not self.visible and now - self.start_time >= 0.5:
111
+ self.visible = True
112
+ self.last_update = 0.0
113
+ if self.is_tty:
114
+ self.console.show_cursor(False)
115
+
116
+ if not self.visible or now - self.last_update < 0.1:
117
+ return
118
+
119
+ self.last_update = now
120
+ frame_str = self._next_frame()
121
+
122
+ # Determine the maximum width for the spinner line
123
+ # Subtract 2 as requested, to leave a margin or prevent cursor wrapping issues
124
+ max_spinner_width = self.console.width - 2
125
+ if max_spinner_width < 0: # Handle extremely narrow terminals
126
+ max_spinner_width = 0
127
+
128
+ current_text_payload = f" {self.text}"
129
+ line_to_display = f"{frame_str}{current_text_payload}"
130
+
131
+ # Truncate the line if it's too long for the console width
132
+ if len(line_to_display) > max_spinner_width:
133
+ line_to_display = line_to_display[:max_spinner_width]
134
+
135
+ len_line_to_display = len(line_to_display)
136
+
137
+ # Calculate padding to clear any remnants from a longer previous line
138
+ padding_to_clear = " " * max(0, self.last_display_len - len_line_to_display)
139
+
140
+ # Write the spinner frame, text, and any necessary clearing spaces
141
+ sys.stdout.write(f"\r{line_to_display}{padding_to_clear}")
142
+ self.last_display_len = len_line_to_display
143
+
144
+ # Calculate number of backspaces to position cursor at the scanner character
145
+ scan_char_abs_pos = frame_str.find(self.scan_char)
146
+
147
+ # Total characters written to the line (frame + text + padding)
148
+ total_chars_written_on_line = len_line_to_display + len(padding_to_clear)
149
+
150
+ # num_backspaces will be non-positive if scan_char_abs_pos is beyond
151
+ # total_chars_written_on_line (e.g., if the scan char itself was truncated).
152
+ # (e.g., if the scan char itself was truncated).
153
+ # In such cases, (effectively) 0 backspaces are written,
154
+ # and the cursor stays at the end of the line.
155
+ num_backspaces = total_chars_written_on_line - scan_char_abs_pos
156
+ sys.stdout.write("\b" * num_backspaces)
157
+ sys.stdout.flush()
158
+
159
+ def end(self) -> None:
160
+ if self.visible and self.is_tty:
161
+ clear_len = self.last_display_len # Use the length of the last displayed content
162
+ sys.stdout.write("\r" + " " * clear_len + "\r")
163
+ sys.stdout.flush()
164
+ self.console.show_cursor(True)
165
+ self.visible = False
166
+
167
+
168
+ class WaitingSpinner:
169
+ """Background spinner that can be started/stopped safely."""
170
+
171
+ def __init__(self, text: str = "Waiting for LLM", delay: float = 0.15):
172
+ self.spinner = Spinner(text)
173
+ self.delay = delay
174
+ self._stop_event = threading.Event()
175
+ self._thread = threading.Thread(target=self._spin, daemon=True)
176
+
177
+ def _spin(self):
178
+ try:
179
+ while not self._stop_event.is_set():
180
+ self.spinner.step()
181
+ if self._stop_event.wait(self.delay):
182
+ break
183
+ finally:
184
+ self.spinner.end()
185
+
186
+ def start(self):
187
+ """Start the spinner in a background thread."""
188
+ if not self._thread.is_alive():
189
+ self._thread.start()
190
+
191
+ def stop(self):
192
+ """Request the spinner to stop and wait for the worker to restore the terminal."""
193
+ self._stop_event.set()
194
+ if self._thread.is_alive():
195
+ self._thread.join()
196
+ else:
197
+ self.spinner.end()
198
+
199
+ # Allow use as a context-manager
200
+ def __enter__(self):
201
+ self.start()
202
+ return self
203
+
204
+ def __exit__(self, exc_type, exc_val, exc_tb):
205
+ self.stop()
206
+
207
+
208
+ def main():
209
+ spinner = Spinner("Running spinner...")
210
+ try:
211
+ for _ in range(100):
212
+ time.sleep(0.15)
213
+ spinner.step()
214
+ print("Success!")
215
+ except KeyboardInterrupt:
216
+ print("\nInterrupted by user.")
217
+ finally:
218
+ spinner.end()
219
+
220
+
221
+ if __name__ == "__main__":
222
+ main()