-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement
ChildrenOverflow
for >100 children
- Loading branch information
1 parent
e91bf80
commit d77cc68
Showing
3 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from itertools import islice | ||
|
||
MAX_DISPLAY = 100 | ||
|
||
def get_keys_and_children(inspector): | ||
keys, values = [], [] | ||
keys_iterator = iter(inspector.get_children()) | ||
# positron frontend only displays the first 100 items, then the length of the rest. | ||
try: | ||
for _ in range(MAX_DISPLAY): | ||
key = next(keys_iterator) | ||
keys.append(str(key)) | ||
values.append(inspector.get_child(key)) | ||
except StopIteration: | ||
return keys, values | ||
|
||
n_remaining = 0 | ||
for n_remaining, _ in enumerate(keys_iterator, 1): | ||
pass | ||
if n_remaining > 0: | ||
keys.append("[[...]]") | ||
values.append(ChildrenOverflow(n_remaining)) | ||
|
||
return keys, values | ||
|
||
|
||
def get_child(inspector, index): | ||
key = next(islice(inspector.get_children(), index - 1, None)) | ||
return inspector.get_child(key) | ||
|
||
class ChildrenOverflow: | ||
def __init__(self, n_remaining): | ||
self.n_remaining = n_remaining |