-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from eth-cscs/deploy/reframe-2.6.1
Reframe 2.6.1 public release
- Loading branch information
Showing
48 changed files
with
1,690 additions
and
1,445 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,59 @@ | ||
# | ||
# Internal debug utilities for the framework | ||
# | ||
|
||
import builtins | ||
import threading | ||
|
||
# Current indentation levels per thread | ||
_depth = {} | ||
|
||
|
||
def _gettid(): | ||
tid = threading.get_ident() | ||
_depth.setdefault(tid, 0) | ||
return tid | ||
|
||
|
||
def _increase_indent(): | ||
tid = _gettid() | ||
_depth[tid] += 1 | ||
return _depth[tid] | ||
|
||
|
||
def _decrease_indent(): | ||
tid = _gettid() | ||
_depth[tid] -= 1 | ||
return _depth[tid] | ||
|
||
|
||
def repr(obj, indent=4, max_depth=2): | ||
"""Return a generic representation string for object `obj`. | ||
Keyword arguments: | ||
indent -- indentation width | ||
max_depth -- maximum depth for expanding nested objects | ||
""" | ||
if not hasattr(obj, '__dict__'): | ||
# Delegate to the builtin repr() for builtin types | ||
return builtins.repr(obj) | ||
|
||
tid = _gettid() | ||
indent_width = _increase_indent() * indent | ||
|
||
# Attribute representation | ||
if _depth[tid] == max_depth: | ||
attr_list = ['...'] | ||
else: | ||
attr_list = ['%s%s=%r' % (indent_width * ' ', attr, val) | ||
for attr, val in sorted(obj.__dict__.items())] | ||
|
||
repr_fmt = '%(module_name)s.%(class_name)s(%(attr_repr)s)@0x%(addr)x' | ||
ret = repr_fmt % { | ||
'module_name': obj.__module__, | ||
'class_name': obj.__class__.__name__, | ||
'attr_repr': ',\n'.join(attr_list), | ||
'addr': id(obj) | ||
} | ||
_decrease_indent() | ||
return ret |
Oops, something went wrong.