icplot 0.3.0__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {icplot-0.3.0/src/icplot.egg-info → icplot-0.3.3}/PKG-INFO +1 -1
- {icplot-0.3.0 → icplot-0.3.3}/pyproject.toml +1 -1
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/converter/image.py +21 -1
- icplot-0.3.3/src/icplot/renderer/__init__.py +5 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/formats/mermaid.py +10 -4
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/formats/plantuml.py +3 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/formats/tex.py +5 -2
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/render.py +11 -2
- {icplot-0.3.0 → icplot-0.3.3/src/icplot.egg-info}/PKG-INFO +1 -1
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot.egg-info/SOURCES.txt +1 -0
- icplot-0.3.3/test/test_puml.py +24 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_tex.py +2 -4
- icplot-0.3.0/src/icplot/renderer/__init__.py +0 -1
- {icplot-0.3.0 → icplot-0.3.3}/LICENSE +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/README.md +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/setup.cfg +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/charts/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/charts/gantt.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/charts/tree.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/converter/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/converter/cli.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/converter/convert.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/base.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/cell.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/edge.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/mesh.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/openfoam/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/openfoam/blockmesh.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/openfoam/foamfile.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/openfoam/polymesh.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/operations.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/shapes.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/vertex.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/mesh/vtk.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/operations.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/shapes.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/geometry/transform.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/graph/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/graph/axis.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/graph/plot.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/graph/plot_group.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/graph/series.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/main_cli.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/py.typed +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/charts/pgfgantt.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/charts/svggantt.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/cli.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/config.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/formats/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/color.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/matplotlib.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/mpl.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/renderer.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/graph/vtk.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/scene/cairo.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/renderer/video.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/scene.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/__init__.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/cli.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/color.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/templates/puml.j2 +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/templates/tikz.j2 +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/theme.json +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/theme.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot/theme/theme_generator.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot.egg-info/dependency_links.txt +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot.egg-info/entry_points.txt +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot.egg-info/requires.txt +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/src/icplot.egg-info/top_level.txt +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_cairo.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_gantt_chart.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_geometry.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_image.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_line_plots.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_mermaid.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_meshing.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_openfoam.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_plot_group.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_polymesh.py +0 -0
- {icplot-0.3.0 → icplot-0.3.3}/test/test_tree.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: icplot
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Utilities for generating plots and graphics for technical reports.
|
|
5
5
|
Author-email: "James Grogan, Irish Centre for High End Computing" <james.grogan@ichec.ie>
|
|
6
6
|
Project-URL: Repository, https://git.ichec.ie/performance/toolshed/icplot
|
|
@@ -5,6 +5,8 @@ formats
|
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
7
|
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
8
10
|
from pathlib import Path
|
|
9
11
|
|
|
10
12
|
logger = logging.getLogger(__name__)
|
|
@@ -29,6 +31,10 @@ def has_wand() -> bool:
|
|
|
29
31
|
return _HAS_WAND
|
|
30
32
|
|
|
31
33
|
|
|
34
|
+
def has_magick() -> bool:
|
|
35
|
+
return bool(shutil.which("magick"))
|
|
36
|
+
|
|
37
|
+
|
|
32
38
|
def has_cairo_svg() -> bool:
|
|
33
39
|
return _HAS_CAIRO_SVG
|
|
34
40
|
|
|
@@ -39,13 +45,27 @@ def _get_out_filename(source: Path, target: Path | None, extension: str) -> Path
|
|
|
39
45
|
return source.parent / f"{source.stem}.{extension}"
|
|
40
46
|
|
|
41
47
|
|
|
48
|
+
def _pdf_to_png(source: Path, target: Path | None = None, resolution: int = 300):
|
|
49
|
+
|
|
50
|
+
outfile = _get_out_filename(source, target, "png")
|
|
51
|
+
os.makedirs(outfile.parent, exist_ok=True)
|
|
52
|
+
cmd = (
|
|
53
|
+
f"magick -density {resolution} -background white -alpha off {source} {outfile}"
|
|
54
|
+
)
|
|
55
|
+
subprocess.run(cmd, shell=True, check=True)
|
|
56
|
+
|
|
57
|
+
|
|
42
58
|
def pdf_to_png(source: Path, target: Path | None = None, resolution: int = 300):
|
|
43
59
|
"""
|
|
44
60
|
Convert a pdf to png with white background
|
|
45
61
|
"""
|
|
46
62
|
|
|
47
63
|
if not has_wand():
|
|
48
|
-
|
|
64
|
+
if has_magick():
|
|
65
|
+
_pdf_to_png(source, target, resolution)
|
|
66
|
+
return
|
|
67
|
+
else:
|
|
68
|
+
raise RuntimeError("Loading Wand failed - no pdf to png support")
|
|
49
69
|
|
|
50
70
|
outfile = _get_out_filename(source, target, "png")
|
|
51
71
|
os.makedirs(outfile.parent, exist_ok=True)
|
|
@@ -5,8 +5,10 @@ Mermaid must already be set up on the system, eg. via the npm ecosystem.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
|
+
import os
|
|
8
9
|
import shutil
|
|
9
10
|
import subprocess
|
|
11
|
+
from pathlib import Path
|
|
10
12
|
|
|
11
13
|
from ..config import RenderContext
|
|
12
14
|
|
|
@@ -26,16 +28,20 @@ def render(ctx: RenderContext):
|
|
|
26
28
|
raise RuntimeError("Mermaid CLI 'mmdc' not found in path.")
|
|
27
29
|
|
|
28
30
|
if ctx.output_dir:
|
|
29
|
-
ctx.output_dir.mkdir(exist_ok=True)
|
|
31
|
+
ctx.output_dir.mkdir(exist_ok=True, parents=True)
|
|
30
32
|
output_path = ctx.output_dir / f"{ctx.source.stem}.{ctx.output_type}"
|
|
31
33
|
else:
|
|
32
34
|
output_path = ctx.source.parent / f"{ctx.source.stem}.{ctx.output_type}"
|
|
33
35
|
|
|
34
36
|
logger.info("Rendering: %s -> %s", ctx.source, output_path)
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
if
|
|
38
|
-
|
|
38
|
+
browser_config = ctx.config.mermaid.browser_config
|
|
39
|
+
if not browser_config and (env_path := os.environ.get("MMDC_PUPPETEER_CONFIG")):
|
|
40
|
+
browser_config = Path(env_path)
|
|
41
|
+
|
|
42
|
+
cmd = f"mmdc -i '{ctx.source}' -o '{output_path}'"
|
|
43
|
+
if browser_config:
|
|
44
|
+
cmd += f" -p '{browser_config}'"
|
|
39
45
|
logger.debug("Command: %s", cmd)
|
|
40
46
|
subprocess.run(cmd, shell=True, check=True)
|
|
41
47
|
logger.info("Done: %s", output_path.name)
|
|
@@ -24,6 +24,9 @@ def render(ctx: RenderContext):
|
|
|
24
24
|
logger.info("Rendering: %s -> %s", ctx.source, ctx.output_type)
|
|
25
25
|
|
|
26
26
|
cmd = ["plantuml", f"-t{ctx.output_type}"]
|
|
27
|
+
if ctx.output_dir:
|
|
28
|
+
ctx.output_dir.mkdir(exist_ok=True, parents=True)
|
|
29
|
+
cmd.extend(["-o", str(ctx.output_dir)])
|
|
27
30
|
if ctx.config.plantuml.config_path:
|
|
28
31
|
cmd.extend(["-config", str(ctx.config.plantuml.config_path.resolve())])
|
|
29
32
|
cmd.append(str(ctx.source))
|
|
@@ -37,7 +37,7 @@ def _run_commands(ctx: RenderContext, work_dir: Path):
|
|
|
37
37
|
logger.debug("Engine: %s | work_dir: %s", ctx.config.tex.build_engine, work_dir)
|
|
38
38
|
|
|
39
39
|
if ctx.config.tex.build_engine == "pdflatex":
|
|
40
|
-
cmd = f"{ctx.config.tex.build_engine} {' '.join(extra_flags)} {ctx.source}"
|
|
40
|
+
cmd = f"{ctx.config.tex.build_engine} {' '.join(extra_flags)} '{ctx.source}'"
|
|
41
41
|
logger.info("Command: %s", cmd.strip())
|
|
42
42
|
with open(work_dir / "stdout.txt", "w", encoding="utf-8") as f:
|
|
43
43
|
subprocess.run(
|
|
@@ -45,6 +45,7 @@ def _run_commands(ctx: RenderContext, work_dir: Path):
|
|
|
45
45
|
shell=True,
|
|
46
46
|
check=True,
|
|
47
47
|
cwd=work_dir,
|
|
48
|
+
env=tex_env,
|
|
48
49
|
stdout=f,
|
|
49
50
|
stderr=f,
|
|
50
51
|
stdin=subprocess.DEVNULL,
|
|
@@ -92,7 +93,9 @@ def render(ctx: RenderContext):
|
|
|
92
93
|
work_dir = ctx.build_dir / ctx.source.stem
|
|
93
94
|
work_dir.mkdir(exist_ok=True, parents=True)
|
|
94
95
|
|
|
95
|
-
_run_commands(ctx, work_dir)
|
|
96
|
+
err = _run_commands(ctx, work_dir)
|
|
97
|
+
if err:
|
|
98
|
+
raise RuntimeError(f"Render failed for {ctx.source.name}: {err}")
|
|
96
99
|
|
|
97
100
|
tex_path = work_dir / ctx.source.name
|
|
98
101
|
if ctx.config.tex.build_engine == "pdflatex":
|
|
@@ -61,10 +61,13 @@ def _get_extension(path: Path) -> str:
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
def _collect_sources(root: Path, formats: list[str], excludes: list[str]) -> list[Path]:
|
|
64
|
-
files = []
|
|
64
|
+
files: list[Path] = []
|
|
65
65
|
if root.is_file():
|
|
66
66
|
logger.info("Using source: %s", root)
|
|
67
67
|
suffix = _get_extension(root)
|
|
68
|
+
if suffix not in _ENVIRONMENT_CHECKS:
|
|
69
|
+
logger.warning("Unknown extension .%s — no renderer registered", suffix)
|
|
70
|
+
return files
|
|
68
71
|
if _ENVIRONMENT_CHECKS[suffix]():
|
|
69
72
|
files.append(root)
|
|
70
73
|
else:
|
|
@@ -76,6 +79,9 @@ def _collect_sources(root: Path, formats: list[str], excludes: list[str]) -> lis
|
|
|
76
79
|
if not formats:
|
|
77
80
|
formats = _FORMATS
|
|
78
81
|
for f in formats:
|
|
82
|
+
if f not in _ENVIRONMENT_CHECKS:
|
|
83
|
+
logger.warning("Unknown format requested: %s — skipping", f)
|
|
84
|
+
continue
|
|
79
85
|
if _ENVIRONMENT_CHECKS[f]():
|
|
80
86
|
files.extend(find_files(root, f, excludes))
|
|
81
87
|
else:
|
|
@@ -97,6 +103,9 @@ def _setup_tasks(
|
|
|
97
103
|
output_formats = _DEFAULT_OUTPUT_FORMATS[ext]
|
|
98
104
|
|
|
99
105
|
for fmt in output_formats:
|
|
106
|
+
if ext not in _RENDERERS:
|
|
107
|
+
logger.warning("No renderer for extension .%s — skipping %s", ext, f)
|
|
108
|
+
continue
|
|
100
109
|
tasks.append(
|
|
101
110
|
partial(
|
|
102
111
|
_RENDERERS[ext],
|
|
@@ -135,6 +144,6 @@ def render(
|
|
|
135
144
|
if errors:
|
|
136
145
|
logger.error("%d/%d task(s) failed:", len(errors), len(tasks))
|
|
137
146
|
for task_error in errors:
|
|
138
|
-
logger.error(" %s", task_error[
|
|
147
|
+
logger.error(" %s", task_error.args[0].source.relative_to(root))
|
|
139
148
|
else:
|
|
140
149
|
logger.info("Done — %d/%d task(s) succeeded", succeeded, len(tasks))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: icplot
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Utilities for generating plots and graphics for technical reports.
|
|
5
5
|
Author-email: "James Grogan, Irish Centre for High End Computing" <james.grogan@ichec.ie>
|
|
6
6
|
Project-URL: Repository, https://git.ichec.ie/performance/toolshed/icplot
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
|
|
3
|
+
from iccore.test_utils import get_test_data_dir, get_test_output_dir
|
|
4
|
+
|
|
5
|
+
from icplot.renderer.config import RenderConfig, RenderContext
|
|
6
|
+
from icplot.renderer.formats import plantuml
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_puml():
|
|
10
|
+
|
|
11
|
+
data_dir = get_test_data_dir()
|
|
12
|
+
build_dir = get_test_output_dir()
|
|
13
|
+
|
|
14
|
+
render_ctx = RenderContext(
|
|
15
|
+
config=RenderConfig(),
|
|
16
|
+
source=data_dir / "test.puml",
|
|
17
|
+
output_type="png",
|
|
18
|
+
output_dir=get_test_output_dir(),
|
|
19
|
+
build_dir=get_test_output_dir(),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
plantuml.render(render_ctx)
|
|
23
|
+
|
|
24
|
+
shutil.rmtree(build_dir)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import shutil
|
|
2
|
-
from pathlib import Path
|
|
3
2
|
|
|
4
3
|
from iccore.test_utils import get_test_data_dir, get_test_output_dir
|
|
5
4
|
|
|
6
|
-
from icplot.renderer.config import
|
|
5
|
+
from icplot.renderer.config import RenderConfig, RenderContext
|
|
7
6
|
from icplot.renderer.formats import tex
|
|
8
7
|
|
|
9
8
|
|
|
@@ -11,11 +10,10 @@ def test_tex():
|
|
|
11
10
|
|
|
12
11
|
data_dir = get_test_data_dir()
|
|
13
12
|
build_dir = get_test_output_dir()
|
|
14
|
-
source = data_dir / "test.tex"
|
|
15
13
|
|
|
16
14
|
render_ctx = RenderContext(
|
|
17
15
|
config=RenderConfig(),
|
|
18
|
-
source=
|
|
16
|
+
source=data_dir / "test.tex",
|
|
19
17
|
output_type="png",
|
|
20
18
|
output_dir=get_test_output_dir(),
|
|
21
19
|
build_dir=get_test_output_dir(),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from . import formats # noqa: F401 — trigger handler registration
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|