Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename diagram_cache to diagram_image_cache #353

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capellambse contributors
# SPDX-License-Identifier: Apache-2.0
"""Module to populate the diagram cache with native Capella diagrams."""
"""Module to populate the diagram image cache with native Capella diagrams."""

from __future__ import annotations

Expand Down Expand Up @@ -67,10 +67,10 @@ def export(
background: bool,
) -> None:
if not isinstance(
getattr(model, "_diagram_cache", None), local.LocalFileHandler
getattr(model, "_diagram_image_cache", None), local.LocalFileHandler
):
raise TypeError(
"Diagram cache updates are only supported for local paths"
"Diagram image cache updates are only supported for local paths"
)

format = format.lower()
Expand All @@ -80,12 +80,12 @@ def export(
f"Invalid image format {format!r}, supported are {supported}"
)

diag_cache_dir = pathlib.Path(model._diagram_cache.path)
diag_image_cache_dir = pathlib.Path(model._diagram_image_cache.path)
try:
shutil.rmtree(diag_cache_dir)
shutil.rmtree(diag_image_cache_dir)
except FileNotFoundError:
pass
diag_cache_dir.mkdir(parents=True)
diag_image_cache_dir.mkdir(parents=True)

native_args = _find_executor(model, capella, force)
with _native.native_capella(model, **native_args) as cli:
Expand All @@ -104,12 +104,12 @@ def export(
diagrams = _copy_images(
model,
cli.project / "main_model" / "output",
diag_cache_dir,
diag_image_cache_dir,
format,
background,
)
if index:
_write_index(model, format, diag_cache_dir, diagrams)
_write_index(model, format, diag_image_cache_dir, diagrams)


def _find_executor(
Expand Down Expand Up @@ -249,7 +249,7 @@ def _write_index(
index: list[IndexEntry],
) -> None:
now = datetime.datetime.now().strftime("%A, %Y-%m-%d %H:%M:%S")
title = f"Capella diagram cache for {model.name!r}"
title = f"Capella diagram image cache for {model.name!r}"
html = E.html(
E.head(
E.style(
Expand Down
2 changes: 1 addition & 1 deletion capellambse/cli_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ModelInfoCLI(click.ParamType):
@click.open("-m", "modelinfo", type=capellambse.ModelInfoCLI())
def main(modelinfo: dict[str, t.Any]) -> None:
# change any options, for example:
modelinfo["diagram_cache"] = "/tmp/diagrams"
modelinfo["diagram_image_cache"] = "/tmp/diagrams"
# load the model:
model = capellambse.MelodyModel(**modelinfo)
...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capellambse contributors
# SPDX-License-Identifier: Apache-2.0
"""CLI for the diagram cache updating feature."""
"""CLI for the diagram image cache updating feature."""
from __future__ import annotations

import pathlib
import sys

import capellambse
from capellambse import _diagram_cache, cli_helpers
from capellambse import _diagram_image_cache, cli_helpers

# pylint: disable=unused-import
from capellambse._diagram_cache import IndexEntry
from capellambse._diagram_image_cache import IndexEntry

try:
import click
Expand Down Expand Up @@ -45,7 +45,7 @@ def _main() -> None:
@click.option(
"-f",
"--format",
type=click.Choice(sorted(_diagram_cache.VALID_FORMATS)),
type=click.Choice(sorted(_diagram_image_cache.VALID_FORMATS)),
default="svg",
help="Image output format",
show_default=True,
Expand Down Expand Up @@ -73,11 +73,11 @@ def _main(
docker: str | None,
background: bool,
) -> None:
model_._diagram_cache = capellambse.get_filehandler(output)
model_._diagram_cache_subdir = pathlib.PurePosixPath(".")
model_._diagram_image_cache = capellambse.get_filehandler(output)
model_._diagram_image_cache_subdir = pathlib.PurePosixPath(".")

if docker:
_diagram_cache.export(
_diagram_image_cache.export(
docker,
model_,
format=format,
Expand All @@ -87,7 +87,7 @@ def _main(
)
else:
exe = exe or "capella{VERSION}"
_diagram_cache.export(
_diagram_image_cache.export(
exe,
model_,
format=format,
Expand Down
Loading