Skip to content

Commit ceea3af

Browse files
Fix PR comments
1 parent cc5c704 commit ceea3af

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

core/esmf-aspect-meta-model-python/esmf_aspect_meta_model_python/samm_cli_functions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919

2020
class SammCli:
21-
"""Class to eecute SAMM CLI functions.
21+
"""Class to execute SAMM CLI functions.
2222
23-
If there is no downloaded SAMM CLI, code will identify operation system and download a corresponding client.
23+
If there is no downloaded SAMM CLI, the code will identify the operating system and download a corresponding
24+
SAMM CLI version.
2425
"""
2526

2627
def __init__(self):
@@ -29,23 +30,22 @@ def __init__(self):
2930

3031
@staticmethod
3132
def _get_client_path():
32-
"""Get path to the SAMM Cli executable file.."""
33+
"""Get path to the SAMM CLI executable file.."""
3334
base_path = Path(__file__).resolve()
3435
cli_path = join(base_path.parents[1], "samm-cli", "samm.exe")
3536

3637
return cli_path
3738

3839
def _validate_client(self):
39-
"""Validate SAMM Cli.
40+
"""Validate SAMM CLI.
4041
41-
If there is no SAMM Cli executable file, run a script for downloading.
42+
If there is no SAMM CLI executable file, run a script for downloading.
4243
"""
4344
if not exists(self._samm):
44-
# download SAMM CLI
4545
download_samm_cli()
4646

4747
def _call_function(self, function_name, path_to_model, *args, **kwargs):
48-
"""Run a SAMM Cli function as a subprocess."""
48+
"""Run a SAMM CLI function as a subprocess."""
4949
call_args = [self._samm, "aspect", path_to_model] + function_name.split()
5050

5151
if args:
@@ -78,7 +78,7 @@ def to_openapi(self, path_to_model, *args, **kwargs):
7878
param path_to_model: local path to the aspect model file (*.ttl)
7979
possible arguments:
8080
- output, o: output file path (default: stdout)
81-
- api-base-url, b: the base url for the Aspect API used in the OpenAPI specification, b="http://mysite.de"
81+
- api-base-url, b: the base url for the Aspect API used in the OpenAPI specification, b="http://localhost/"
8282
- json, j: generate a JSON specification for an Aspect Model (default format is YAML)
8383
- comment, c: only in combination with --json; generates $comment OpenAPI 3.1 keyword for all
8484
samm:see attributes

core/esmf-aspect-meta-model-python/scripts/download_samm_cli.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@
1212
import sys
1313
import zipfile
1414

15-
BASE_PATH = "https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.6.1/"
15+
from string import Template
16+
17+
BASE_PATH = Template("https://github.com/eclipse-esmf/esmf-sdk/releases/download/v$version_number/$file_name")
18+
LINUX_FILE_NAME = Template("samm-cli-$version_number-linux-x86_64.tar.gz")
19+
SAMM_CLI_VERSION = "2.6.1"
20+
WIN_FILE_NAME = Template("samm-cli-$version_number-windows-x86_64.zip")
1621

1722

1823
def get_samm_cli_file_name():
1924
"""Get a SAMM CLI file name for the current platform."""
2025

2126
if platform.system() == "Windows":
22-
file_name = "samm-cli-2.6.1-windows-x86_64.zip"
27+
file_name = WIN_FILE_NAME.substitute(version_number=SAMM_CLI_VERSION)
2328
elif platform.system() == "Linux":
24-
file_name = "samm-cli-2.6.1-linux-x86_64.tar.gz"
29+
file_name = LINUX_FILE_NAME.substitute(version_number=SAMM_CLI_VERSION)
2530
else:
26-
raise NotImplementedError(f"Please download a SAMM CLI manually for your operation system from '{BASE_PATH}'")
31+
raise NotImplementedError(
32+
f"Please download a SAMM CLI manually for your operation system from '{BASE_PATH}'"
33+
)
2734

2835
return file_name
2936

@@ -60,17 +67,17 @@ def download_samm_cli():
6067
print(error)
6168
else:
6269
print(f"Start downloading SAMM CLI {samm_cli_file_name}")
63-
url = BASE_PATH + samm_cli_file_name
64-
dir_path = Path(__file__).resolve().parent
65-
archive_file = os.path.join(dir_path, f".\\{samm_cli_file_name}")
70+
url = BASE_PATH.substitute(version_number=SAMM_CLI_VERSION, file_name=samm_cli_file_name)
71+
dir_path = Path(__file__).resolve().parents[1]
72+
archive_file = os.path.join(dir_path, samm_cli_file_name)
6673

6774
download_archive_file(url, archive_file)
68-
print("SAMM CLI archive file downloaded")
75+
print("\nSAMM CLI archive file downloaded")
6976

7077
print("Start extracting files")
7178
archive = zipfile.ZipFile(archive_file)
7279
for file in archive.namelist():
73-
archive.extract(file, ".\\samm-cli")
80+
archive.extract(file, "samm-cli")
7481
archive.close()
7582
print("Done extracting files.")
7683

0 commit comments

Comments
 (0)