peek-python 26.0.4__tar.gz → 26.0.6__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.
- {peek_python-26.0.4 → peek_python-26.0.6}/PKG-INFO +24 -16
- {peek_python-26.0.4 → peek_python-26.0.6}/README.md +23 -15
- {peek_python-26.0.4 → peek_python-26.0.6}/peek/peek.py +119 -126
- {peek_python-26.0.4 → peek_python-26.0.6}/peek_python.egg-info/PKG-INFO +24 -16
- {peek_python-26.0.4 → peek_python-26.0.6}/pyproject.toml +1 -1
- {peek_python-26.0.4 → peek_python-26.0.6}/tests/test_peek.py +41 -11
- {peek_python-26.0.4 → peek_python-26.0.6}/peek/__init__.py +0 -0
- {peek_python-26.0.4 → peek_python-26.0.6}/peek_python.egg-info/SOURCES.txt +0 -0
- {peek_python-26.0.4 → peek_python-26.0.6}/peek_python.egg-info/dependency_links.txt +0 -0
- {peek_python-26.0.4 → peek_python-26.0.6}/peek_python.egg-info/requires.txt +0 -0
- {peek_python-26.0.4 → peek_python-26.0.6}/peek_python.egg-info/top_level.txt +0 -0
- {peek_python-26.0.4 → peek_python-26.0.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: peek-python
|
|
3
|
-
Version: 26.0.
|
|
3
|
+
Version: 26.0.6
|
|
4
4
|
Summary: peek - like print, but easy
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/peek
|
|
@@ -671,15 +671,30 @@ prints something like
|
|
|
671
671
|
```
|
|
672
672
|
#4 in x()
|
|
673
673
|
Traceback (most recent call last)
|
|
674
|
-
File
|
|
674
|
+
File 'x.py', line 6, in <module>
|
|
675
675
|
x()
|
|
676
|
-
File
|
|
676
|
+
File 'x.py', line 4, in x
|
|
677
677
|
peek()
|
|
678
678
|
#4 in x()
|
|
679
679
|
Traceback (most recent call last)
|
|
680
|
-
File
|
|
680
|
+
File 'x.py', line 7, in <module>
|
|
681
681
|
x()
|
|
682
|
-
File
|
|
682
|
+
File 'x.py', line 4, in x
|
|
683
|
+
peek()
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
If show_traceback is an integer, it depicts the maximum depth of the shown traceback. So:
|
|
687
|
+
```
|
|
688
|
+
def x():
|
|
689
|
+
peek(show_traceback=1)
|
|
690
|
+
|
|
691
|
+
x()
|
|
692
|
+
```
|
|
693
|
+
prints something like
|
|
694
|
+
```
|
|
695
|
+
#4 in x()
|
|
696
|
+
Traceback (most recent call last)
|
|
697
|
+
File 'x.py', line 4, in x
|
|
683
698
|
peek()
|
|
684
699
|
```
|
|
685
700
|
The `show_traceback` functionality is also available when peek is used as a decorator or context manager.
|
|
@@ -1212,16 +1227,16 @@ in red, but only if peek.enabled is True (which is the default).
|
|
|
1212
1227
|
In order to behave similar to print, `peek` has an extra attribute, `separator_print` (alias: `sepp`). This attribute (default " ") will be used when `peek.printing`.
|
|
1213
1228
|
When calling `peek.print`, `sep` may be used instead. So
|
|
1214
1229
|
|
|
1215
|
-
|
|
1230
|
+
```
|
|
1216
1231
|
peek.sepp = "|"
|
|
1217
1232
|
peek.print("test")
|
|
1218
|
-
|
|
1233
|
+
```
|
|
1219
1234
|
|
|
1220
1235
|
Has the same effect as
|
|
1221
1236
|
|
|
1222
|
-
```
|
|
1237
|
+
```
|
|
1223
1238
|
peek.print("test", sep="|")
|
|
1224
|
-
```
|
|
1239
|
+
```
|
|
1225
1240
|
|
|
1226
1241
|
and
|
|
1227
1242
|
|
|
@@ -1620,13 +1635,6 @@ It is not possible to use peek:
|
|
|
1620
1635
|
* from a frozen application (e.g. packaged with PyInstaller)
|
|
1621
1636
|
* when the underlying source code has changed during execution
|
|
1622
1637
|
|
|
1623
|
-
## Changelog
|
|
1624
|
-
|
|
1625
|
-
The changelog can be found here:
|
|
1626
|
-
|
|
1627
|
-
* https://github.com/salabim/peek/blob/main/changelog.md or
|
|
1628
|
-
* https://salabim.org/peek/changelog
|
|
1629
|
-
|
|
1630
1638
|
|
|
1631
1639
|
## Acknowledgement
|
|
1632
1640
|
|
|
@@ -654,15 +654,30 @@ prints something like
|
|
|
654
654
|
```
|
|
655
655
|
#4 in x()
|
|
656
656
|
Traceback (most recent call last)
|
|
657
|
-
File
|
|
657
|
+
File 'x.py', line 6, in <module>
|
|
658
658
|
x()
|
|
659
|
-
File
|
|
659
|
+
File 'x.py', line 4, in x
|
|
660
660
|
peek()
|
|
661
661
|
#4 in x()
|
|
662
662
|
Traceback (most recent call last)
|
|
663
|
-
File
|
|
663
|
+
File 'x.py', line 7, in <module>
|
|
664
664
|
x()
|
|
665
|
-
File
|
|
665
|
+
File 'x.py', line 4, in x
|
|
666
|
+
peek()
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
If show_traceback is an integer, it depicts the maximum depth of the shown traceback. So:
|
|
670
|
+
```
|
|
671
|
+
def x():
|
|
672
|
+
peek(show_traceback=1)
|
|
673
|
+
|
|
674
|
+
x()
|
|
675
|
+
```
|
|
676
|
+
prints something like
|
|
677
|
+
```
|
|
678
|
+
#4 in x()
|
|
679
|
+
Traceback (most recent call last)
|
|
680
|
+
File 'x.py', line 4, in x
|
|
666
681
|
peek()
|
|
667
682
|
```
|
|
668
683
|
The `show_traceback` functionality is also available when peek is used as a decorator or context manager.
|
|
@@ -1195,16 +1210,16 @@ in red, but only if peek.enabled is True (which is the default).
|
|
|
1195
1210
|
In order to behave similar to print, `peek` has an extra attribute, `separator_print` (alias: `sepp`). This attribute (default " ") will be used when `peek.printing`.
|
|
1196
1211
|
When calling `peek.print`, `sep` may be used instead. So
|
|
1197
1212
|
|
|
1198
|
-
|
|
1213
|
+
```
|
|
1199
1214
|
peek.sepp = "|"
|
|
1200
1215
|
peek.print("test")
|
|
1201
|
-
|
|
1216
|
+
```
|
|
1202
1217
|
|
|
1203
1218
|
Has the same effect as
|
|
1204
1219
|
|
|
1205
|
-
```
|
|
1220
|
+
```
|
|
1206
1221
|
peek.print("test", sep="|")
|
|
1207
|
-
```
|
|
1222
|
+
```
|
|
1208
1223
|
|
|
1209
1224
|
and
|
|
1210
1225
|
|
|
@@ -1603,13 +1618,6 @@ It is not possible to use peek:
|
|
|
1603
1618
|
* from a frozen application (e.g. packaged with PyInstaller)
|
|
1604
1619
|
* when the underlying source code has changed during execution
|
|
1605
1620
|
|
|
1606
|
-
## Changelog
|
|
1607
|
-
|
|
1608
|
-
The changelog can be found here:
|
|
1609
|
-
|
|
1610
|
-
* https://github.com/salabim/peek/blob/main/changelog.md or
|
|
1611
|
-
* https://salabim.org/peek/changelog
|
|
1612
|
-
|
|
1613
1621
|
|
|
1614
1622
|
## Acknowledgement
|
|
1615
1623
|
|
|
@@ -34,7 +34,7 @@ import pprint
|
|
|
34
34
|
import builtins
|
|
35
35
|
import shutil
|
|
36
36
|
|
|
37
|
-
__version__ = "26.0.
|
|
37
|
+
__version__ = "26.0.6"
|
|
38
38
|
|
|
39
39
|
from pathlib import Path
|
|
40
40
|
|
|
@@ -151,8 +151,6 @@ class _Peek:
|
|
|
151
151
|
|
|
152
152
|
ANSI = types.SimpleNamespace(**_color_name_to_ANSI)
|
|
153
153
|
|
|
154
|
-
codes = {}
|
|
155
|
-
|
|
156
154
|
@staticmethod
|
|
157
155
|
def de_alias(name):
|
|
158
156
|
if name == "c":
|
|
@@ -170,75 +168,75 @@ class _Peek:
|
|
|
170
168
|
|
|
171
169
|
if value is None:
|
|
172
170
|
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
raise AttributeError("output should be a callable, str, Path or open text file.")
|
|
171
|
+
if name == "output":
|
|
172
|
+
if callable(value):
|
|
173
|
+
return
|
|
174
|
+
if isinstance(value, (str, Path)):
|
|
175
|
+
return
|
|
176
|
+
try:
|
|
177
|
+
value.write("")
|
|
178
|
+
return
|
|
179
|
+
except Exception:
|
|
180
|
+
pass
|
|
181
|
+
raise AttributeError("output should be a callable, str, Path or open text file.")
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
elif name == "serialize":
|
|
184
|
+
if callable(value):
|
|
185
|
+
return
|
|
189
186
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
elif name in ("color", "color_value"):
|
|
188
|
+
if isinstance(value, str) and value in _Peek._color_name_to_ANSI:
|
|
189
|
+
return
|
|
190
|
+
if isinstance(value, int) and value in _Peek.id_to_color:
|
|
191
|
+
return
|
|
195
192
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
elif name == "delta":
|
|
194
|
+
if isinstance(value, numbers.Number):
|
|
195
|
+
return
|
|
199
196
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
elif name == "line_length":
|
|
198
|
+
if (isinstance(value, numbers.Number) and value >= 0) or value == "terminal_width":
|
|
199
|
+
return
|
|
203
200
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
elif name == "indent":
|
|
202
|
+
if isinstance(value, numbers.Number) and value >= 0:
|
|
203
|
+
return
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
elif name == "level":
|
|
206
|
+
if isinstance(value, numbers.Number):
|
|
207
|
+
return
|
|
211
208
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
elif name == "max_lines":
|
|
210
|
+
if isinstance(value, numbers.Number) and value > 0:
|
|
211
|
+
return
|
|
215
212
|
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
elif name == "wrap_indent":
|
|
214
|
+
if isinstance(value, str):
|
|
215
|
+
return
|
|
216
|
+
if isinstance(value, numbers.Number):
|
|
217
|
+
if value > 0:
|
|
218
218
|
return
|
|
219
|
-
if isinstance(value, numbers.Number):
|
|
220
|
-
if value > 0:
|
|
221
|
-
return
|
|
222
219
|
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
elif name == "format":
|
|
221
|
+
if isinstance(value, str):
|
|
222
|
+
return
|
|
223
|
+
try:
|
|
224
|
+
if all(isinstance(sub_format, str) for sub_format in value):
|
|
225
225
|
return
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
-
except TypeError:
|
|
230
|
-
...
|
|
226
|
+
except TypeError:
|
|
227
|
+
...
|
|
231
228
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return
|
|
238
|
-
except Exception:
|
|
239
|
-
...
|
|
240
|
-
case _:
|
|
229
|
+
elif name == "filter":
|
|
230
|
+
if value.strip() == "":
|
|
231
|
+
return
|
|
232
|
+
try:
|
|
233
|
+
eval(value, _Peek.name_and_alias_default)
|
|
241
234
|
return
|
|
235
|
+
except Exception:
|
|
236
|
+
...
|
|
237
|
+
|
|
238
|
+
else:
|
|
239
|
+
return
|
|
242
240
|
|
|
243
241
|
raise AttributeError(f"incorrect {name_org}: {repr(value)}{_Peek.in_read_toml_message}")
|
|
244
242
|
|
|
@@ -308,28 +306,15 @@ class _Peek:
|
|
|
308
306
|
s = s[1:]
|
|
309
307
|
print(cached + end, end="", file=file)
|
|
310
308
|
|
|
311
|
-
def print_without_color(s, end="\n", file=sys.stdout):
|
|
312
|
-
while s:
|
|
313
|
-
for ansi, rgb in _Peek._ANSI_to_rgb.items():
|
|
314
|
-
if s.startswith(ansi):
|
|
315
|
-
s = s[len(ansi) :]
|
|
316
|
-
break
|
|
317
|
-
else:
|
|
318
|
-
print(s[0], end="", file=file)
|
|
319
|
-
s = s[1:]
|
|
320
|
-
print("", end=end, file=file)
|
|
321
|
-
|
|
322
309
|
@staticmethod
|
|
323
310
|
def return_args(args, return_none):
|
|
324
311
|
if return_none:
|
|
325
312
|
return None
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
case _:
|
|
332
|
-
return args
|
|
313
|
+
if len(args) == 0:
|
|
314
|
+
return None
|
|
315
|
+
if len(args) == 1:
|
|
316
|
+
return args[0]
|
|
317
|
+
return args
|
|
333
318
|
|
|
334
319
|
@staticmethod
|
|
335
320
|
def perf_counter():
|
|
@@ -362,16 +347,15 @@ class _Peek:
|
|
|
362
347
|
node = self
|
|
363
348
|
while item not in node._attributes or node._attributes[item] is None:
|
|
364
349
|
node = node._parent
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return node._attributes[item]
|
|
350
|
+
if item == "delta":
|
|
351
|
+
return _Peek.perf_counter() - node._attributes["delta1"] + node._attributes["delta"]
|
|
352
|
+
elif item == "delta1":
|
|
353
|
+
return node._attributes["delta"]
|
|
354
|
+
elif item == "prefix":
|
|
355
|
+
prefix = node._attributes[item]
|
|
356
|
+
return str(prefix() if callable(prefix) else prefix)
|
|
357
|
+
else:
|
|
358
|
+
return node._attributes[item]
|
|
375
359
|
else:
|
|
376
360
|
return self.__getattribute__(item)
|
|
377
361
|
|
|
@@ -462,7 +446,7 @@ class _Peek:
|
|
|
462
446
|
if this.decorator and this.context_manager:
|
|
463
447
|
raise AttributeError("not allowed to specify both decorator and context_manager")
|
|
464
448
|
|
|
465
|
-
Pair =
|
|
449
|
+
Pair = types.SimpleNamespace
|
|
466
450
|
|
|
467
451
|
call_frame = inspect.currentframe()
|
|
468
452
|
filename0 = call_frame.f_code.co_filename
|
|
@@ -545,11 +529,6 @@ class _Peek:
|
|
|
545
529
|
if call_node is None:
|
|
546
530
|
this._line_number_with_filename_and_parent = ""
|
|
547
531
|
else:
|
|
548
|
-
# line_number = call_node.lineno
|
|
549
|
-
# try:
|
|
550
|
-
# this_line = code[line_number - 1].strip()
|
|
551
|
-
# except IndexError:
|
|
552
|
-
# this_line = ""
|
|
553
532
|
this._line_number_with_filename_and_parent = f"#{line_number}{filename_name}{parent_function}"
|
|
554
533
|
|
|
555
534
|
if this.context_manager:
|
|
@@ -754,34 +733,34 @@ class _Peek:
|
|
|
754
733
|
self.output(s_end, end="")
|
|
755
734
|
else:
|
|
756
735
|
self.output(s_end)
|
|
736
|
+
elif self.output in ("stdout", "stderr"):
|
|
737
|
+
file = sys.stdout if self.output == "stdout" else sys.stderr
|
|
738
|
+
if Pythonista:
|
|
739
|
+
_Peek.print_pythonista_color(s_end, end="", file=file)
|
|
740
|
+
# elif Pyodide: # not handled via use_color
|
|
741
|
+
# _Peek.print_without_color(s, end=self.end, file=file)
|
|
742
|
+
else:
|
|
743
|
+
print(s_end, end="", file=file)
|
|
744
|
+
elif self.output == "logging.debug":
|
|
745
|
+
logging.debug(s)
|
|
746
|
+
elif self.output == "logging.info":
|
|
747
|
+
logging.info(s)
|
|
748
|
+
elif self.output == "logging.warning":
|
|
749
|
+
logging.warning(s)
|
|
750
|
+
elif self.output == "logging.error":
|
|
751
|
+
logging.error(s)
|
|
752
|
+
elif self.output == "logging.critical":
|
|
753
|
+
logging.critical(s)
|
|
754
|
+
elif self.output in ("", "null"):
|
|
755
|
+
pass
|
|
756
|
+
elif isinstance(self.output, str):
|
|
757
|
+
with open(self.output, "a+", encoding="utf-8") as f:
|
|
758
|
+
print(s_end, file=f, end="")
|
|
759
|
+
elif isinstance(self.output, Path):
|
|
760
|
+
with self.output.open("a+", encoding="utf-8") as f:
|
|
761
|
+
print(s_end, file=f, end="")
|
|
757
762
|
else:
|
|
758
|
-
|
|
759
|
-
case "stdout" | "stderr":
|
|
760
|
-
file = sys.stdout if self.output == "stdout" else sys.stderr
|
|
761
|
-
if Pythonista:
|
|
762
|
-
_Peek.print_pythonista_color(s_end, end="", file=file)
|
|
763
|
-
else:
|
|
764
|
-
print(s_end, end="", file=file)
|
|
765
|
-
case "logging.debug":
|
|
766
|
-
logging.debug(s)
|
|
767
|
-
case "logging.info":
|
|
768
|
-
logging.info(s)
|
|
769
|
-
case "logging.warning":
|
|
770
|
-
logging.warning(s)
|
|
771
|
-
case "logging.error":
|
|
772
|
-
logging.error(s)
|
|
773
|
-
case "logging.critical":
|
|
774
|
-
logging.critical(s)
|
|
775
|
-
case "" | "null":
|
|
776
|
-
pass
|
|
777
|
-
case _ if isinstance(self.output, str):
|
|
778
|
-
with open(self.output, "a+", encoding="utf-8") as f:
|
|
779
|
-
print(s_end, file=f, end="")
|
|
780
|
-
case _ if isinstance(self.output, Path):
|
|
781
|
-
with self.output.open("a+", encoding="utf-8") as f:
|
|
782
|
-
print(s_end, file=f, end="")
|
|
783
|
-
case _:
|
|
784
|
-
print(s_end, file=self.output, end="")
|
|
763
|
+
print(s_end, file=self.output, end="")
|
|
785
764
|
|
|
786
765
|
def copy_to_clipboard(self, value, confirm=True):
|
|
787
766
|
if Pythonista:
|
|
@@ -810,17 +789,30 @@ class _Peek:
|
|
|
810
789
|
|
|
811
790
|
def traceback(self):
|
|
812
791
|
if self.show_traceback:
|
|
792
|
+
if self.show_traceback is True:
|
|
793
|
+
n = 1_000_000
|
|
794
|
+
else:
|
|
795
|
+
n = self.show_traceback
|
|
813
796
|
if isinstance(self.wrap_indent, numbers.Number):
|
|
814
797
|
wrap_indent = int(self.wrap_indent) * " "
|
|
815
798
|
else:
|
|
816
799
|
wrap_indent = str(self.wrap_indent)
|
|
817
800
|
|
|
818
|
-
result = "
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
for
|
|
823
|
-
|
|
801
|
+
result = ["", f"{wrap_indent}Traceback (most recent call last)"]
|
|
802
|
+
entries = []
|
|
803
|
+
for entry in traceback.extract_stack()[::-1]:
|
|
804
|
+
filename = Path(entry.filename).name
|
|
805
|
+
if filename != "peek.py": # this for pytest,which adds two extra levels
|
|
806
|
+
entries.append(entry)
|
|
807
|
+
n -= 1
|
|
808
|
+
if n == 0:
|
|
809
|
+
break
|
|
810
|
+
for entry in entries[::-1]:
|
|
811
|
+
filename = Path(entry.filename).name
|
|
812
|
+
result.append(f"{wrap_indent} File {filename!r}, line {entry.lineno} in {entry.name}")
|
|
813
|
+
result.append(f"{wrap_indent} {entry.line}")
|
|
814
|
+
|
|
815
|
+
return "\n".join(result)
|
|
824
816
|
else:
|
|
825
817
|
return ""
|
|
826
818
|
|
|
@@ -891,3 +883,4 @@ reset()
|
|
|
891
883
|
|
|
892
884
|
if __name__ != "__main__":
|
|
893
885
|
sys.modules["peek"].__class__ = _PeekModule
|
|
886
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: peek-python
|
|
3
|
-
Version: 26.0.
|
|
3
|
+
Version: 26.0.6
|
|
4
4
|
Summary: peek - like print, but easy
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/peek
|
|
@@ -671,15 +671,30 @@ prints something like
|
|
|
671
671
|
```
|
|
672
672
|
#4 in x()
|
|
673
673
|
Traceback (most recent call last)
|
|
674
|
-
File
|
|
674
|
+
File 'x.py', line 6, in <module>
|
|
675
675
|
x()
|
|
676
|
-
File
|
|
676
|
+
File 'x.py', line 4, in x
|
|
677
677
|
peek()
|
|
678
678
|
#4 in x()
|
|
679
679
|
Traceback (most recent call last)
|
|
680
|
-
File
|
|
680
|
+
File 'x.py', line 7, in <module>
|
|
681
681
|
x()
|
|
682
|
-
File
|
|
682
|
+
File 'x.py', line 4, in x
|
|
683
|
+
peek()
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
If show_traceback is an integer, it depicts the maximum depth of the shown traceback. So:
|
|
687
|
+
```
|
|
688
|
+
def x():
|
|
689
|
+
peek(show_traceback=1)
|
|
690
|
+
|
|
691
|
+
x()
|
|
692
|
+
```
|
|
693
|
+
prints something like
|
|
694
|
+
```
|
|
695
|
+
#4 in x()
|
|
696
|
+
Traceback (most recent call last)
|
|
697
|
+
File 'x.py', line 4, in x
|
|
683
698
|
peek()
|
|
684
699
|
```
|
|
685
700
|
The `show_traceback` functionality is also available when peek is used as a decorator or context manager.
|
|
@@ -1212,16 +1227,16 @@ in red, but only if peek.enabled is True (which is the default).
|
|
|
1212
1227
|
In order to behave similar to print, `peek` has an extra attribute, `separator_print` (alias: `sepp`). This attribute (default " ") will be used when `peek.printing`.
|
|
1213
1228
|
When calling `peek.print`, `sep` may be used instead. So
|
|
1214
1229
|
|
|
1215
|
-
|
|
1230
|
+
```
|
|
1216
1231
|
peek.sepp = "|"
|
|
1217
1232
|
peek.print("test")
|
|
1218
|
-
|
|
1233
|
+
```
|
|
1219
1234
|
|
|
1220
1235
|
Has the same effect as
|
|
1221
1236
|
|
|
1222
|
-
```
|
|
1237
|
+
```
|
|
1223
1238
|
peek.print("test", sep="|")
|
|
1224
|
-
```
|
|
1239
|
+
```
|
|
1225
1240
|
|
|
1226
1241
|
and
|
|
1227
1242
|
|
|
@@ -1620,13 +1635,6 @@ It is not possible to use peek:
|
|
|
1620
1635
|
* from a frozen application (e.g. packaged with PyInstaller)
|
|
1621
1636
|
* when the underlying source code has changed during execution
|
|
1622
1637
|
|
|
1623
|
-
## Changelog
|
|
1624
|
-
|
|
1625
|
-
The changelog can be found here:
|
|
1626
|
-
|
|
1627
|
-
* https://github.com/salabim/peek/blob/main/changelog.md or
|
|
1628
|
-
* https://salabim.org/peek/changelog
|
|
1629
|
-
|
|
1630
1638
|
|
|
1631
1639
|
## Acknowledgement
|
|
1632
1640
|
|
|
@@ -691,6 +691,22 @@ def test_as_decorator(capsys):
|
|
|
691
691
|
out, err = capsys.readouterr()
|
|
692
692
|
assert out.startswith("called add2(3)\nreturned 5 from add2(3) in ")
|
|
693
693
|
|
|
694
|
+
@peek.as_decorator
|
|
695
|
+
def add2(x):
|
|
696
|
+
return x + 2
|
|
697
|
+
|
|
698
|
+
add2(3)
|
|
699
|
+
out, err = capsys.readouterr()
|
|
700
|
+
assert out.startswith("called add2(3)\nreturned 5 from add2(3) in ")
|
|
701
|
+
|
|
702
|
+
@peek.as_d
|
|
703
|
+
def add2(x):
|
|
704
|
+
return x + 2
|
|
705
|
+
|
|
706
|
+
add2(3)
|
|
707
|
+
out, err = capsys.readouterr()
|
|
708
|
+
assert out.startswith("called add2(3)\nreturned 5 from add2(3) in ")
|
|
709
|
+
|
|
694
710
|
|
|
695
711
|
def test_as_context_manager(capsys):
|
|
696
712
|
with peek.as_context_manager():
|
|
@@ -963,22 +979,35 @@ def test_wrap_indent():
|
|
|
963
979
|
|
|
964
980
|
def test_traceback(capsys):
|
|
965
981
|
with peek.preserve():
|
|
982
|
+
|
|
983
|
+
def x():
|
|
984
|
+
peek()
|
|
985
|
+
|
|
986
|
+
def y():
|
|
987
|
+
x()
|
|
988
|
+
|
|
966
989
|
peek.show_traceback = True
|
|
967
|
-
|
|
990
|
+
y()
|
|
968
991
|
out, err = capsys.readouterr()
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
pass
|
|
992
|
+
out_lines = out.splitlines()
|
|
993
|
+
assert out_lines[-2].endswith("in x")
|
|
994
|
+
assert out_lines[-4].endswith("in y")
|
|
995
|
+
assert out_lines[-6].endswith("in test_traceback")
|
|
974
996
|
|
|
975
|
-
|
|
997
|
+
peek.show_traceback = 1
|
|
998
|
+
y()
|
|
976
999
|
out, err = capsys.readouterr()
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1000
|
+
out_lines = out.splitlines()
|
|
1001
|
+
assert len(out_lines) == 4
|
|
1002
|
+
assert out_lines[-2].endswith("in x")
|
|
1003
|
+
|
|
1004
|
+
peek.show_traceback = 2
|
|
1005
|
+
y()
|
|
980
1006
|
out, err = capsys.readouterr()
|
|
981
|
-
|
|
1007
|
+
out_lines = out.splitlines()
|
|
1008
|
+
assert len(out_lines) == 6
|
|
1009
|
+
assert out_lines[-2].endswith("in x")
|
|
1010
|
+
assert out_lines[-4].endswith("in y")
|
|
982
1011
|
|
|
983
1012
|
|
|
984
1013
|
def test_check_output(capsys, tmpdir):
|
|
@@ -1353,3 +1382,4 @@ def test_line_length():
|
|
|
1353
1382
|
|
|
1354
1383
|
if __name__ == "__main__":
|
|
1355
1384
|
pytest.main(["-vv", "-s", "-x", __file__])
|
|
1385
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|