Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Mar 16, 2021
1 parent ca6d71a commit 7be58b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion climetlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .plotting import plot_map
from .sources import load as load_source

__version__ = "0.3.13"
__version__ = "0.3.14"


__all__ = [
Expand Down
27 changes: 24 additions & 3 deletions climetlab/core/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,37 @@ def guess_which_ipython():
return ("unknown", None)


def tidy(x):
if x is None:
return x

if isinstance(x, (list, tuple)):
return [tidy(y) for y in x]

if isinstance(x, dict):
r = {}
for k, v in x.items():
r[str(k)] = tidy(v)
return r

if isinstance(x, (int, float, str)):
return x

import re

return re.sub(r" object at x\w+", repr(x), "")


def ipython_environment():
import json
import IPython

r = {}
k = IPython.get_ipython()
for n in dir(k):
if not callable(getattr(k, n)):
r[n] = repr(getattr(k, n))
print(json.dumps(r, sort_keys=True, indent=4))
if not callable(getattr(k, n)) and not n.startswith("__"):
r[n] = getattr(k, n)
print(json.dumps(tidy(r), sort_keys=True, indent=4))


def enable_ipython_login(level=logging.INFO):
Expand Down

0 comments on commit 7be58b7

Please sign in to comment.