peek-python 26.1.1__tar.gz → 26.1.1.post1__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.1.1 → peek_python-26.1.1.post1}/PKG-INFO +1 -1
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek/peek.py +25 -28
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek_python.egg-info/PKG-INFO +1 -1
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/pyproject.toml +1 -1
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/tests/test_peek.py +1 -1
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/README.md +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek/__init__.py +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek_python.egg-info/SOURCES.txt +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek_python.egg-info/dependency_links.txt +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek_python.egg-info/requires.txt +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/peek_python.egg-info/top_level.txt +0 -0
- {peek_python-26.1.1 → peek_python-26.1.1.post1}/setup.cfg +0 -0
|
@@ -53,6 +53,8 @@ try:
|
|
|
53
53
|
except ModuleNotFoundError:
|
|
54
54
|
import tomli as tomllib
|
|
55
55
|
|
|
56
|
+
lf="\n"
|
|
57
|
+
|
|
56
58
|
|
|
57
59
|
class _Peek:
|
|
58
60
|
name_alias_default = (
|
|
@@ -65,7 +67,7 @@ class _Peek:
|
|
|
65
67
|
("delta", "", 0),
|
|
66
68
|
("depth", "", 1000000),
|
|
67
69
|
("enabled", "", True),
|
|
68
|
-
("end", "",
|
|
70
|
+
("end", "", lf),
|
|
69
71
|
("equals_separator", "", "="),
|
|
70
72
|
("filter", "f", ""),
|
|
71
73
|
("format", "fmt", ""),
|
|
@@ -288,7 +290,7 @@ class _Peek:
|
|
|
288
290
|
return result
|
|
289
291
|
|
|
290
292
|
@staticmethod
|
|
291
|
-
def print_pythonista_color(s, end=
|
|
293
|
+
def print_pythonista_color(s, end=lf, file=sys.stdout):
|
|
292
294
|
cached = ""
|
|
293
295
|
while s:
|
|
294
296
|
for ansi, rgb in _Peek._ANSI_to_rgb.items():
|
|
@@ -304,7 +306,7 @@ class _Peek:
|
|
|
304
306
|
s = s[1:]
|
|
305
307
|
print(cached + end, end="", file=file)
|
|
306
308
|
|
|
307
|
-
def return_args(self,args):
|
|
309
|
+
def return_args(self, args):
|
|
308
310
|
if self.return_none:
|
|
309
311
|
return None
|
|
310
312
|
if len(args) == 0:
|
|
@@ -362,17 +364,12 @@ class _Peek:
|
|
|
362
364
|
self._attributes.update(_Peek.spec_to_attributes(**{item: value}))
|
|
363
365
|
|
|
364
366
|
def __repr__(self):
|
|
365
|
-
pairs = [
|
|
366
|
-
|
|
367
|
-
]
|
|
368
|
-
return "peek.new(" + ", ".join(pairs) + ")"
|
|
367
|
+
pairs = [f"{name}={getattr(self, 'delta1') if name == 'delta' else getattr(self, name)!r}" for name in _Peek.name_default if name != "serialize"]
|
|
368
|
+
return f"peek.new({', '.join(pairs)})"
|
|
369
369
|
|
|
370
370
|
def __str__(self):
|
|
371
|
-
pairs = [
|
|
372
|
-
|
|
373
|
-
]
|
|
374
|
-
|
|
375
|
-
return "peek with attributes:\n " + "\n ".join(pairs) + ")"
|
|
371
|
+
pairs = [f"{name}={getattr(self, 'delta1') if name == 'delta' else getattr(self, name)!r}" for name in _Peek.name_default if name != "serialize"]
|
|
372
|
+
return f"peek with attributes:{lf} {'{lf} '.join(pairs)}"
|
|
376
373
|
|
|
377
374
|
def fix_perf_counter(self, val): # for tests
|
|
378
375
|
_Peek._fixed_perf_counter = val
|
|
@@ -396,9 +393,9 @@ class _Peek:
|
|
|
396
393
|
def add_to_pairs(pairs, left, right):
|
|
397
394
|
if right is locals or right is globals or right is vars:
|
|
398
395
|
frame = inspect.currentframe().f_back
|
|
399
|
-
peek_filename=frame.f_code.co_filename
|
|
400
|
-
while frame is not None and frame.f_code.co_filename==peek_filename:
|
|
401
|
-
frame=frame.f_back
|
|
396
|
+
peek_filename = frame.f_code.co_filename
|
|
397
|
+
while frame is not None and frame.f_code.co_filename == peek_filename:
|
|
398
|
+
frame = frame.f_back
|
|
402
399
|
for name, value in {locals: frame.f_locals, globals: frame.f_globals, vars: frame.f_locals}[right].items():
|
|
403
400
|
if not (isinstance(value, _PeekModule) or name.startswith("__")):
|
|
404
401
|
pairs.append(Pair(left=f"{name}{this.equals_separator}", right=value))
|
|
@@ -408,7 +405,7 @@ class _Peek:
|
|
|
408
405
|
this = self.fork(**kwargs)
|
|
409
406
|
if not this.do_show():
|
|
410
407
|
if this.as_timer:
|
|
411
|
-
this._real_decorator=lambda x:x
|
|
408
|
+
this._real_decorator = lambda x: x
|
|
412
409
|
return _Timer(this)
|
|
413
410
|
else:
|
|
414
411
|
if as_str:
|
|
@@ -465,7 +462,7 @@ class _Peek:
|
|
|
465
462
|
if (filename.startswith("<") and filename.endswith(">")) or (main_file_resolved is None) or (filename_resolved == main_file_resolved):
|
|
466
463
|
filename_name = ""
|
|
467
464
|
else:
|
|
468
|
-
filename_name = "[
|
|
465
|
+
filename_name = f"[{os.path.basename(filename)}]"
|
|
469
466
|
|
|
470
467
|
frame_info = inspect.getframeinfo(call_frame, context=1)
|
|
471
468
|
if frame_info.code_context is None:
|
|
@@ -536,7 +533,7 @@ class _Peek:
|
|
|
536
533
|
source = executing.Source.for_frame(call_frame)
|
|
537
534
|
for node, right in zip(call_node.args, args):
|
|
538
535
|
left = source.asttokens().get_text(node)
|
|
539
|
-
if
|
|
536
|
+
if lf in left:
|
|
540
537
|
left = " " * node.first_token.start[1] + left
|
|
541
538
|
left = textwrap.dedent(left)
|
|
542
539
|
try:
|
|
@@ -562,10 +559,10 @@ class _Peek:
|
|
|
562
559
|
just_one_line = False
|
|
563
560
|
|
|
564
561
|
if not (len(pairs) > 1 and this.separator == ""):
|
|
565
|
-
if not any(
|
|
562
|
+
if not any(lf in pair.left for pair in pairs):
|
|
566
563
|
as_one_line = context + this.separator.join(pair.left + this.serialize_kwargs(obj=pair.right, width=10000) for pair in pairs)
|
|
567
564
|
# as_one_line = context + this.separator.join(pair.left + (this.serialize_kwargs(obj=pair.right, width=10000)) for pair in pairs)
|
|
568
|
-
if len(as_one_line) <= this.line_length and
|
|
565
|
+
if len(as_one_line) <= this.line_length and lf not in as_one_line:
|
|
569
566
|
out += as_one_line
|
|
570
567
|
just_one_line = True
|
|
571
568
|
|
|
@@ -591,14 +588,14 @@ class _Peek:
|
|
|
591
588
|
|
|
592
589
|
for pair in pairs:
|
|
593
590
|
do_right = False
|
|
594
|
-
if
|
|
591
|
+
if lf in pair.left:
|
|
595
592
|
for s in pair.left.splitlines():
|
|
596
593
|
lines.append(indent1 + s)
|
|
597
594
|
do_right = True
|
|
598
595
|
else:
|
|
599
596
|
start = indent1 + pair.left
|
|
600
597
|
line = start + this.serialize_kwargs(obj=pair.right, width=this.line_length - len(start))
|
|
601
|
-
if
|
|
598
|
+
if lf in line:
|
|
602
599
|
lines.append(start)
|
|
603
600
|
do_right = True
|
|
604
601
|
else:
|
|
@@ -611,7 +608,7 @@ class _Peek:
|
|
|
611
608
|
lines.append(indent2 + s)
|
|
612
609
|
if len(lines) > this.max_lines:
|
|
613
610
|
lines = lines[: this.max_lines] + ["[abbreviated]"]
|
|
614
|
-
out +=
|
|
611
|
+
out += lf.join(line.rstrip() for line in lines)
|
|
615
612
|
|
|
616
613
|
else:
|
|
617
614
|
if not this.show_line_number: # if "n" or "no parent", keep that info
|
|
@@ -625,7 +622,7 @@ class _Peek:
|
|
|
625
622
|
if as_str:
|
|
626
623
|
if this.use_color and this.color not in ("", "-"):
|
|
627
624
|
out = f"{_Peek._color_name_to_ANSI[this.color.lower()]}{out}{_Peek._color_name_to_ANSI['-']}"
|
|
628
|
-
if this.end ==
|
|
625
|
+
if this.end == lf:
|
|
629
626
|
out += this.end
|
|
630
627
|
else:
|
|
631
628
|
out += f"{_Peek._color_name_to_ANSI[this.color.lower()]}{this.end}{_Peek._color_name_to_ANSI['-']}"
|
|
@@ -638,7 +635,7 @@ class _Peek:
|
|
|
638
635
|
this.do_output(out)
|
|
639
636
|
|
|
640
637
|
return this.return_args(args)
|
|
641
|
-
|
|
638
|
+
|
|
642
639
|
def timer(self, *args, **kwargs):
|
|
643
640
|
return self(*args, **kwargs | dict(as_timer=True))
|
|
644
641
|
|
|
@@ -682,8 +679,8 @@ class _Peek:
|
|
|
682
679
|
def do_output(self, s):
|
|
683
680
|
if self.use_color and self.color not in ("", "-"):
|
|
684
681
|
s_end = f"{_Peek._color_name_to_ANSI[self.color.lower()]}{s}{_Peek._color_name_to_ANSI['-']}"
|
|
685
|
-
if self.end ==
|
|
686
|
-
s_end +=
|
|
682
|
+
if self.end == lf:
|
|
683
|
+
s_end += lf
|
|
687
684
|
else:
|
|
688
685
|
s_end += f"{_Peek._color_name_to_ANSI[self.color.lower()]}{self.end}{_Peek._color_name_to_ANSI['-']}"
|
|
689
686
|
else:
|
|
@@ -774,7 +771,7 @@ class _Peek:
|
|
|
774
771
|
result.append(f"{wrap_indent} File {filename!r}, line {entry.lineno} in {entry.name}")
|
|
775
772
|
result.append(f"{wrap_indent} {entry.line}")
|
|
776
773
|
|
|
777
|
-
return
|
|
774
|
+
return lf.join(result)
|
|
778
775
|
else:
|
|
779
776
|
return ""
|
|
780
777
|
|
|
@@ -192,7 +192,7 @@ def test_repr_and_str(capsys):
|
|
|
192
192
|
print(str(peek))
|
|
193
193
|
out, err = capsys.readouterr()
|
|
194
194
|
assert out.startswith("peek with attributes:")
|
|
195
|
-
assert out.endswith("
|
|
195
|
+
assert out.endswith("\n")
|
|
196
196
|
|
|
197
197
|
print(repr(peek))
|
|
198
198
|
out, err = capsys.readouterr()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|