ScriptCollection 4.2.129__py3-none-any.whl → 4.2.130__py3-none-any.whl

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.
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
38
38
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
39
  from .SCLog import SCLog, LogLevel
40
40
 
41
- version = "4.2.129"
41
+ version = "4.2.130"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -123,9 +123,23 @@ class TFCPS_Tools_General:
123
123
  @GeneralUtilities.check_arguments
124
124
  def ensure_file_from_github_assets_is_available(self,githubuser: str, githubprojectname: str, local_resource_name: str, local_filename: str, get_filename_on_github,enforce_update:bool,pinned_version:str=None) -> str:
125
125
  #TODO use or remove target_folder-parameter
126
- resource_folder =os.path.join( self.__sc.get_global_cache_folder(),"Tools",local_resource_name)
126
+ resource_folder = os.path.join(self.__sc.get_global_cache_folder(), "Tools", local_resource_name)
127
127
  file = f"{resource_folder}/{local_filename}"
128
+ version_file = os.path.join(resource_folder, "Version.txt")
129
+ cached_version: str = None
130
+ if os.path.isfile(version_file):
131
+ cached_version = GeneralUtilities.read_text_from_file(version_file).strip()
128
132
  file_exists = os.path.isfile(file)
133
+ # If a specific version is requested but the cache holds a different one, drop the cache entirely.
134
+ if pinned_version is not None and cached_version is not None and cached_version != pinned_version:
135
+ self.__sc.log.log(f"Cached version of '{local_resource_name}' is '{cached_version}' but pinned version is '{pinned_version}'. Removing cache and re-downloading.", LogLevel.Information)
136
+ GeneralUtilities.ensure_directory_does_not_exist(resource_folder)
137
+ file_exists = False
138
+ cached_version = None
139
+ if enforce_update:
140
+ GeneralUtilities.ensure_directory_does_not_exist(resource_folder)
141
+ file_exists = False
142
+ cached_version = None
129
143
  if not file_exists:
130
144
  self.__sc.log.log(f"Download Asset \"{githubuser}/{githubprojectname}: {local_resource_name}\" from GitHub to global cache...", LogLevel.Information)
131
145
  # Only ensure the folder exists; do NOT empty it. Several assets (e.g. the
@@ -167,6 +181,9 @@ class TFCPS_Tools_General:
167
181
  # Downloaded binaries (e.g. cyclonedx-linux-x64) are written without the
168
182
  # executable bit; make them runnable so they can be executed directly.
169
183
  os.chmod(file, 0o755)
184
+ # Record the requested version state: the pinned tag if one was given, otherwise the literal "latest".
185
+ recorded_version = pinned_version if pinned_version is not None else "latest"
186
+ GeneralUtilities.write_text_to_file(version_file, recorded_version)
170
187
  GeneralUtilities.assert_file_exists(file)
171
188
  return file
172
189
 
@@ -1095,7 +1112,7 @@ class TFCPS_Tools_General:
1095
1112
 
1096
1113
  @GeneralUtilities.check_arguments
1097
1114
  def generate_api_client_from_dependent_codeunit(self, codeunit_folder:str, name_of_api_providing_codeunit: str, target_subfolder_in_codeunit: str,language:str,use_cache:bool,properties:list[str]) -> None:
1098
- openapigenerator_jar_file = self.ensure_openapigenerator_is_available(use_cache)
1115
+ openapigenerator_jar_file = self.ensure_openapigenerator_is_available(use_cache, os.path.dirname(codeunit_folder))
1099
1116
  openapi_spec_file = os.path.join(codeunit_folder, "Other", "Resources", "DependentCodeUnits", name_of_api_providing_codeunit, "APISpecification", f"{name_of_api_providing_codeunit}.latest.api.json")
1100
1117
  target_folder = os.path.join(codeunit_folder, target_subfolder_in_codeunit)
1101
1118
  GeneralUtilities.ensure_folder_exists_and_is_empty(target_folder)
@@ -1115,19 +1132,40 @@ class TFCPS_Tools_General:
1115
1132
  GeneralUtilities.write_text_to_file(packagejson_file, GeneralUtilities.read_text_from_file(packagejson_file).replace("\r", ""))
1116
1133
 
1117
1134
  @GeneralUtilities.check_arguments
1118
- def ensure_openapigenerator_is_available(self,use_cache:bool) -> None:
1135
+ def ensure_openapigenerator_is_available(self, use_cache: bool, repository_folder: str = None) -> str:
1119
1136
  openapigenerator_folder = os.path.join(self.__sc.get_global_cache_folder(), "Tools", "OpenAPIGenerator")
1120
1137
  filename = "open-api-generator.jar"
1121
1138
  jar_file = f"{openapigenerator_folder}/{filename}"
1139
+ cache_version_file = os.path.join(openapigenerator_folder, "Version.txt")
1140
+ # Resolve the desired version from the repo's Version.txt (analogous to PlantUML).
1141
+ pinned_version: str = None
1142
+ if repository_folder is not None:
1143
+ pinned_version = self.get_latest_version_of_openapigenerator(repository_folder)
1144
+ # Read what version is currently in the cache.
1145
+ cached_version: str = None
1146
+ if os.path.isfile(cache_version_file):
1147
+ cached_version = GeneralUtilities.read_text_from_file(cache_version_file).strip()
1122
1148
  jar_file_exists = os.path.isfile(jar_file)
1123
- update:bool=not jar_file_exists or not use_cache
1124
- if update:
1125
- self.__sc.log.log("Download OpenAPIGeneratorCLI...",LogLevel.Debug)
1126
- used_version ="7.16.0"#TODO retrieve latest version
1127
- download_link = f"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/{used_version}/openapi-generator-cli-{used_version}.jar"
1149
+ # Mismatch: a different version is pinned than what's cached — drop the cache so the right one gets downloaded.
1150
+ if pinned_version is not None and cached_version is not None and cached_version != pinned_version:
1151
+ self.__sc.log.log(f"Cached OpenAPIGenerator version is '{cached_version}' but pinned version is '{pinned_version}'. Removing cache and re-downloading.", LogLevel.Information)
1152
+ GeneralUtilities.ensure_directory_does_not_exist(openapigenerator_folder)
1153
+ jar_file_exists = False
1154
+ cached_version = None
1155
+ # Caller explicitly asked to bypass the cache.
1156
+ if not use_cache:
1128
1157
  GeneralUtilities.ensure_directory_does_not_exist(openapigenerator_folder)
1158
+ jar_file_exists = False
1159
+ cached_version = None
1160
+ if not jar_file_exists:
1161
+ self.__sc.log.log("Download OpenAPIGeneratorCLI...", LogLevel.Debug)
1162
+ if pinned_version is None:
1163
+ raise ValueError(f"OpenAPIGenerator version is not pinned for this repository. Expected '<repo>/Other/Resources/Dependencies/OpenAPIGenerator/Version.txt' to exist and contain a Maven-format version (e.g. '7.23.0').")
1164
+ version_to_download = pinned_version
1165
+ download_link = f"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/{version_to_download}/openapi-generator-cli-{version_to_download}.jar"
1129
1166
  GeneralUtilities.ensure_directory_exists(openapigenerator_folder)
1130
1167
  urllib.request.urlretrieve(download_link, jar_file)
1168
+ GeneralUtilities.write_text_to_file(cache_version_file, version_to_download)
1131
1169
  GeneralUtilities.assert_file_exists(jar_file)
1132
1170
  return jar_file
1133
1171
 
@@ -1153,12 +1191,10 @@ class TFCPS_Tools_General:
1153
1191
  GeneralUtilities.write_text_to_file(version_file, used_version)
1154
1192
 
1155
1193
  @GeneralUtilities.check_arguments
1156
- def get_latest_version_of_openapigenerator(self) -> None:
1157
- headers = {'Cache-Control': 'no-cache'}
1158
- self.__add_github_api_key_if_available(headers)
1159
- response = requests.get(f"https://api.github.com/repos/OpenAPITools/openapi-generator/releases", headers=headers, timeout=(10, 10))
1160
- latest_version = response.json()["tag_name"]
1161
- return latest_version
1194
+ def get_latest_version_of_openapigenerator(self, repository_folder: str) -> str:
1195
+ version_file = os.path.join(repository_folder, "Other", "Resources", "Dependencies", "OpenAPIGenerator", "Version.txt")
1196
+ GeneralUtilities.assert_file_exists(version_file)
1197
+ return GeneralUtilities.read_text_from_file(version_file).strip()
1162
1198
 
1163
1199
  @GeneralUtilities.check_arguments
1164
1200
  def update_images_in_example_with_default_excluded(self, codeunit_folder: str,custom_updater:AbstractImageHandler):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.129
3
+ Version: 4.2.130
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=4lxbUFMIWMbthM5Q_QaFjvZfAsNpKlXeqfEbiofg_DI,5109
11
11
  ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
12
- ScriptCollection/ScriptCollectionCore.py,sha256=o1hV5jRYHVu_m44zKs19R9Jfin-xBTckFzMIh7UTvAA,206484
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=RMFlAlNtz_nyOB9reMNFZWj-qf8BOKc6hYY3aR1aDLQ,206484
13
13
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
15
15
  ScriptCollection/OCIImages/OCIImageManager.py,sha256=en97kK75sc7ZJOkX7VE_ZwycfasTBAQQCSQdPIYC91s,12451
@@ -32,7 +32,7 @@ ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=Tpzgiz6m3-cYCkObZOG5Uu7oM-EMoWFzz
32
32
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Vwj7IWmvwIICXiv7I-c6MkxbqlRWCEwzaKW6dgEUjCM,7480
33
33
  ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=m8YGyt3w31U2izXm-DsM2tHjJfXTsceSCu_VjfCilxA,22225
34
34
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=f0Uq1cA_4LvmL72cal0crrbKF6PcxL13D9wBKuQ1YBw,2328
35
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=949bvmKc3fddp9HQEnnzu15_rD85bBRaYKzPS0Ppaps,108252
35
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=TCsHGuTnPveEpYippdDt98eUGorWSsh-0R6Xv9-yuWE,111133
36
36
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=wS2yzYUmJ4m0cf6cBYVTHsiXSXfYhHoLFFy8x6yEQvY,19573
38
38
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -53,8 +53,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK
53
53
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
55
55
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
- scriptcollection-4.2.129.dist-info/METADATA,sha256=8xUMclwCZf5951kP6Upod8NK8i3ZVss2Ls-7YCrSK8g,7697
57
- scriptcollection-4.2.129.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
- scriptcollection-4.2.129.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
- scriptcollection-4.2.129.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
- scriptcollection-4.2.129.dist-info/RECORD,,
56
+ scriptcollection-4.2.130.dist-info/METADATA,sha256=wY4mB6pTsWyTK8UQO61o5nY0qNMDigV9iG3tfCQp-5k,7697
57
+ scriptcollection-4.2.130.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
+ scriptcollection-4.2.130.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
+ scriptcollection-4.2.130.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
+ scriptcollection-4.2.130.dist-info/RECORD,,