@@ -200,8 +200,8 @@ class PaneContentWaiter:
200
200
>>> hasattr(waiter, 'wait_until_ready')
201
201
True
202
202
203
- >>> # Real-world usage examples
204
- >>> # A functional example: send text to the pane and wait for it
203
+ A functional example: send text to the pane and wait for it:
204
+
205
205
>>> # First, send "hello world" to the pane
206
206
>>> pane.send_keys("echo 'hello world'", enter=True)
207
207
>>>
@@ -212,27 +212,42 @@ class PaneContentWaiter:
212
212
>>> "hello world" in result.matched_content
213
213
True
214
214
>>>
215
- >>> # Basic usage (showing API only, other examples)
216
- >>> # result = PaneContentWaiter(pane).wait_for_text("other example")
217
- >>>
218
- >>> # With options
219
- >>> # result = (
220
- >>> # PaneContentWaiter(pane)
221
- >>> # .with_timeout(10.0)
222
- >>> # .wait_for_exact_text("completed successfully")
223
- >>> # )
224
- >>>
225
- >>> # Wait for regex pattern
226
- >>> # result = (
227
- >>> # PaneContentWaiter(pane)
228
- >>> # .with_timeout(10.0)
229
- >>> # .wait_for_regex(r"Process \d+ completed")
230
- >>> # )
231
- >>>
232
- >>> # Custom predicate
215
+
216
+ With options:
217
+
218
+ >>> result = (
219
+ ... PaneContentWaiter(pane)
220
+ ... .with_timeout(5.0)
221
+ ... .wait_for_text("hello world")
222
+ ... )
223
+
224
+ Wait for regex pattern:
225
+
226
+ >>> pane.send_keys("echo 'Process 0 completed.", enter=True)
227
+ >>> result = (
228
+ ... PaneContentWaiter(pane)
229
+ ... .with_timeout(10.0)
230
+ ... .wait_for_regex(r"Process \d+ completed")
231
+ ... )
232
+
233
+ Custom predicate:
234
+
235
+ >>> pane.send_keys("echo 'We are ready!'", enter=True)
233
236
>>> def is_ready(content):
234
237
... return any("ready" in line.lower() for line in content)
235
- >>> # result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
238
+ >>> result = PaneContentWaiter(pane).wait_for_predicate(is_ready)
239
+
240
+ Timeout:
241
+
242
+ >>> try:
243
+ ... result = (
244
+ ... PaneContentWaiter(pane)
245
+ ... .with_timeout(0.01)
246
+ ... .wait_for_exact_text("hello world")
247
+ ... )
248
+ ... except WaitTimeout:
249
+ ... print('No exact match')
250
+ No exact match
236
251
"""
237
252
238
253
def __init__ (self , pane : Pane ) -> None :
0 commit comments