diff --git a/climetlab/plotting/drivers/magics/actions.py b/climetlab/plotting/drivers/magics/actions.py index bedfcab5..3e53d716 100644 --- a/climetlab/plotting/drivers/magics/actions.py +++ b/climetlab/plotting/drivers/magics/actions.py @@ -40,6 +40,9 @@ def __repr__(self): x.append("\n )") return "".join(x) + def to_yaml(self): + return {self.action: self.kwargs} + @property def action(self): return self.__class__.__name__ diff --git a/climetlab/plotting/drivers/magics/driver.py b/climetlab/plotting/drivers/magics/driver.py index 909bbd6f..8589621e 100644 --- a/climetlab/plotting/drivers/magics/driver.py +++ b/climetlab/plotting/drivers/magics/driver.py @@ -9,6 +9,7 @@ import logging import os +import yaml from climetlab.core.bbox import BoundingBox from climetlab.core.caching import temp_file @@ -78,6 +79,10 @@ def temporary_file(self, extension: str = ".tmp") -> str: :return: Temporary file name. :rtype: str """ + + if self._options("dump_yaml", False): + return temp_file(extension).path + self._tmp.append(temp_file(extension)) return self._tmp[-1].path @@ -334,13 +339,16 @@ def show(self): self._options("update", False) self._options("update_foreground", False) - self._options.check_unused() - args = [page] + self.macro() - if int(os.environ.get("CLIMETLAB_DEBUG", "0")): + if self._options("dump_python", False): print(args) + if self._options("dump_yaml", False): + print(yaml.dump(dict(plot=[a.to_yaml() for a in args]), default_flow_style=False)) + + self._options.check_unused() + try: plot(*args) except Exception: diff --git a/pytest.ini b/pytest.ini index 4f779f55..683b4f4d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -; addopts=--cov climetlab --verbose --cov-report xml --cov-report html +addopts=-s --cov climetlab --verbose --cov-report xml --cov-report html ; addopts=--no-cov -addopts=--verbose +; addopts=--verbose