Skip to content

Commit

Permalink
[mycpp] Pretty print OrderedDict more nicely
Browse files Browse the repository at this point in the history
[soil] Add jq to dev-minimal image.  Rebuilt it.
  • Loading branch information
Andy C committed Jun 4, 2022
1 parent 06bab04 commit 71d1f5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions mycpp/collections_.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,16 @@ def __repr__(self, _repr_running={}):
return '...'
_repr_running[call_key] = 1
try:
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
# Oil patch: use <> as a subtle indicator of OrderedDict
parts = ['<']
for i, key in enumerate(self):
if i != 0:
parts.append(', ')
parts.append('%r: ' % key)
parts.append('%r' % self[key])
parts.append('>')
return ''.join(parts)

finally:
del _repr_running[call_key]

Expand Down
3 changes: 3 additions & 0 deletions soil/deps-apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ dev-minimal() {

# Note: osh-minimal task needs shells; not using spec-bin for now
busybox-static mksh zsh

# for oil-spec task
jq
)

apt-get install -y "${packages[@]}"
Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ hay() {
}

hay-isolation() {
sh-spec spec/hay-isolation.test.sh --osh-failures-allowed 10 \
sh-spec spec/hay-isolation.test.sh --osh-failures-allowed 0 \
$OSH_LIST "$@"
}

Expand Down

0 comments on commit 71d1f5b

Please sign in to comment.