ScriptCollection 4.2.121__py3-none-any.whl → 4.2.123__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.121"
41
+ version = "4.2.123"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -310,8 +310,10 @@ class ScriptCollectionCore:
310
310
 
311
311
 
312
312
  @GeneralUtilities.check_arguments
313
- def python_file_has_errors(self, file: str, working_directory: str, treat_warnings_as_errors: bool = True) -> tuple[bool, list[str]]:
313
+ def python_file_has_errors(self, file: str, working_directory: str, treat_warnings_as_errors: bool = True, display_file: str = None) -> tuple[bool, list[str]]:
314
314
  errors = list()
315
+ if display_file is None:
316
+ display_file = file
315
317
  filename = os.path.relpath(file, working_directory)
316
318
  if treat_warnings_as_errors:
317
319
  errorsonly_argument = GeneralUtilities.empty_string
@@ -319,7 +321,7 @@ class ScriptCollectionCore:
319
321
  errorsonly_argument = " --errors-only"
320
322
  (exit_code, stdout, stderr, _) = self.run_program("pylint", filename + errorsonly_argument, working_directory, throw_exception_if_exitcode_is_not_zero=False)
321
323
  if (exit_code != 0):
322
- errors.append(f"Linting-issues of {file}:")
324
+ errors.append(f"Linting-issues of {display_file}:")
323
325
  errors.append(f"Pylint-exitcode: {exit_code}")
324
326
  for line in GeneralUtilities.string_to_lines(stdout):
325
327
  errors.append(line)
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import re
3
+ import tempfile
3
4
  from ...GeneralUtilities import GeneralUtilities,Dependency
4
5
  from ...SCLog import LogLevel
5
6
  from ..TFCPS_CodeUnitSpecific_Base import TFCPS_CodeUnitSpecific_Base,TFCPS_CodeUnitSpecific_Base_CLI
@@ -53,22 +54,33 @@ class TFCPS_CodeUnitSpecific_Python_Functions(TFCPS_CodeUnitSpecific_Base):
53
54
  @GeneralUtilities.check_arguments
54
55
  def linting(self) -> None:
55
56
  codeunitname: str = self.get_codeunit_name()
56
-
57
+
57
58
  repository_folder: str = self.get_repository_folder()
59
+ codeunit_folder = os.path.join(repository_folder, codeunitname)
58
60
  errors_found = False
59
61
  self._protected_sc.log.log(f"Check for linting-issues in codeunit {codeunitname}.")
60
- src_folder = os.path.join(repository_folder, codeunitname, codeunitname)
62
+ src_folder = os.path.join(codeunit_folder, codeunitname)
61
63
  tests_folder = src_folder+"Tests"
62
- # TODO check if there are errors in sarif-file
63
- for file in GeneralUtilities.get_all_files_of_folder(src_folder)+GeneralUtilities.get_all_files_of_folder(tests_folder):
64
- relative_file_path_in_repository = os.path.relpath(file, repository_folder)
65
- if file.endswith(".py") and os.path.getsize(file) > 0 and not self._protected_sc.file_is_git_ignored(relative_file_path_in_repository, repository_folder):
66
- self._protected_sc.log.log(f"Check for linting-issues in {os.path.relpath(file, os.path.join(repository_folder, codeunitname))}.")
67
- linting_result = self._protected_sc.python_file_has_errors(file, repository_folder)
68
- if (linting_result[0]):
69
- errors_found = True
70
- for error in linting_result[1]:
71
- self._protected_sc.log.log(error, LogLevel.Warning)
64
+ # The codeunit gets linted in an isolated folder which only contains this codeunit. This is required because otherwise sibling-codeunit-source-folders of the repository would shadow the installed dependency-packages of the same name during pylint's import-resolution (pylint adds the repository-folder to sys.path due to the package-nesting), which would result in false-positive import-errors. In the isolated folder the declared (and installed) dependency-codeunits are resolved instead.
65
+ ignored_subfolders = ["Other", "__pycache__", "*.egg-info", "build", "dist", "venv", ".venv", ".pytest_cache", ".git"]
66
+ with tempfile.TemporaryDirectory() as isolation_folder:
67
+ isolated_codeunit_folder = os.path.join(isolation_folder, codeunitname)
68
+ GeneralUtilities.copy_content_of_folder(codeunit_folder, isolated_codeunit_folder, ignored_glob_patterms=ignored_subfolders)
69
+ pylint_configuration_file = os.path.join(repository_folder, ".pylintrc")
70
+ if os.path.isfile(pylint_configuration_file):
71
+ GeneralUtilities.safe_copy(pylint_configuration_file, os.path.join(isolation_folder, ".pylintrc"))
72
+ # TODO check if there are errors in sarif-file
73
+ for file in GeneralUtilities.get_all_files_of_folder(src_folder)+GeneralUtilities.get_all_files_of_folder(tests_folder):
74
+ relative_file_path_in_repository = os.path.relpath(file, repository_folder)
75
+ if file.endswith(".py") and os.path.getsize(file) > 0 and not self._protected_sc.file_is_git_ignored(relative_file_path_in_repository, repository_folder):
76
+ relative_file_path_in_codeunit = os.path.relpath(file, codeunit_folder)
77
+ self._protected_sc.log.log(f"Check for linting-issues in {relative_file_path_in_codeunit}.")
78
+ isolated_file = os.path.join(isolated_codeunit_folder, relative_file_path_in_codeunit)
79
+ linting_result = self._protected_sc.python_file_has_errors(isolated_file, isolation_folder, display_file=file)
80
+ if (linting_result[0]):
81
+ errors_found = True
82
+ for error in linting_result[1]:
83
+ self._protected_sc.log.log(error, LogLevel.Warning)
72
84
  if errors_found:
73
85
  raise ValueError("Linting-issues occurred.")
74
86
  else:
@@ -1305,6 +1305,7 @@ class TFCPS_Tools_General:
1305
1305
  GeneralUtilities.assert_file_exists(os.path.join(codeunit_folder, "ReadMe.md"))
1306
1306
  self.__sc.run_program_with_retry("docker-pushrm", target_image_address, codeunit_folder)
1307
1307
 
1308
+ @GeneralUtilities.check_arguments
1308
1309
  def push_docker_build_artifact_as_multi_arch_artifact(self,tar_files: list[tuple[str, str, str]], image_address: str, tag: str):
1309
1310
  """
1310
1311
  tar_files: list of (tar_path, os, arch) tuples
@@ -1458,6 +1459,7 @@ class TFCPS_Tools_General:
1458
1459
  - Updated geo-ip-database.
1459
1460
  """)
1460
1461
 
1462
+ @GeneralUtilities.check_arguments
1461
1463
  def set_latest_version_for_clone_repository_as_resource(self,repository_folder:str, resourcename: str, github_link: str, branch: str = "main"):
1462
1464
  resrepo_commit_id_folder: str = os.path.join(repository_folder, "Other", "Resources", f"{resourcename}Version")
1463
1465
  resrepo_commit_id_file: str = os.path.join(resrepo_commit_id_folder, f"{resourcename}Version.txt")
@@ -1554,6 +1556,7 @@ class TFCPS_Tools_General:
1554
1556
  arguments_for_log=arguments
1555
1557
  self.__sc.run_program_with_retry("docker",arguments,test_service_folder,arguments_for_log=arguments_for_log,print_live_output=self.__sc.log.loglevel==LogLevel.Debug)
1556
1558
 
1559
+ @GeneralUtilities.check_arguments
1557
1560
  def load_deb_control_file_content(self, file: str, codeunitname: str, codeunitversion: str, installedsize: int, maintainername: str, maintaineremail: str, description: str) -> str:
1558
1561
  content = GeneralUtilities.read_text_from_file(file)
1559
1562
  content = GeneralUtilities.replace_variable_in_string(content, "codeunitname", codeunitname)
@@ -1564,6 +1567,7 @@ class TFCPS_Tools_General:
1564
1567
  content = GeneralUtilities.replace_variable_in_string(content, "description", description)
1565
1568
  return content
1566
1569
 
1570
+ @GeneralUtilities.check_arguments
1567
1571
  def calculate_deb_package_size(self, binary_folder: str) -> int:
1568
1572
  size_in_bytes = 0
1569
1573
  for file in GeneralUtilities.get_all_files_of_folder(binary_folder):
@@ -1571,6 +1575,7 @@ class TFCPS_Tools_General:
1571
1575
  result = math.ceil(size_in_bytes/1024)
1572
1576
  return result
1573
1577
 
1578
+ @GeneralUtilities.check_arguments
1574
1579
  def create_deb_package_for_artifact(self,codeunit_folder: str, maintainername: str, maintaineremail: str, description: str) -> None:
1575
1580
  self.assert_is_codeunit_folder(codeunit_folder)
1576
1581
  codeunit_name = os.path.basename(codeunit_folder)
@@ -1591,6 +1596,7 @@ class TFCPS_Tools_General:
1591
1596
  GeneralUtilities.ensure_folder_exists_and_is_empty(target_folder)
1592
1597
  shutil.move(archive_file, target_folder)
1593
1598
 
1599
+ @GeneralUtilities.check_arguments
1594
1600
  def generate_winget_zip_manifest(self, codeunit_folder: str, artifact_name_of_zip: str):
1595
1601
  self.assert_is_codeunit_folder(codeunit_folder)
1596
1602
  codeunit_name = os.path.basename(codeunit_folder)
@@ -1610,7 +1616,8 @@ class TFCPS_Tools_General:
1610
1616
  manifest_content = GeneralUtilities.replace_variable_in_string(manifest_content, "sha256_hashvalue", GeneralUtilities.get_sha256_of_file(artifacts_file))
1611
1617
  GeneralUtilities.write_text_to_file(winget_manifest_file, manifest_content)
1612
1618
 
1613
- def download_file(self,source:str,target:str):
1619
+ @GeneralUtilities.check_arguments
1620
+ def download_file(self,source:str, target:str):
1614
1621
  GeneralUtilities.ensure_directory_exists(os.path.dirname(target))
1615
1622
  GeneralUtilities.ensure_file_exists(target)
1616
1623
  response = requests.get(source, timeout=30)
@@ -1618,16 +1625,44 @@ class TFCPS_Tools_General:
1618
1625
  with open(target, "wb") as f:
1619
1626
  f.write(response.content)
1620
1627
 
1621
- def try_update_basic_codeunitreference_from_examples_repository(self,codeunit_folder:str,example_codeunit_name: str):
1628
+ @GeneralUtilities.check_arguments
1629
+ def try_update_basic_codeunitreference_from_examples_repository(self, codeunit_folder:str,example_codeunit_name: str):
1622
1630
  source=f"https://raw.githubusercontent.com/anionDev/CommonProjectStructureExamples/refs/heads/main/{example_codeunit_name}/Other/Reference/ReferenceContent/HowToBuild.md"
1623
1631
  target=f"{codeunit_folder}/Other/Reference/ReferenceContent/HowToBuild.md"
1624
1632
  self.download_file(source,target)
1625
1633
 
1626
- def try_update_basic_repositoryreference_from_examples_repository(self,repository_folder:str):
1634
+ @GeneralUtilities.check_arguments
1635
+ def try_update_basic_repositoryreference_from_examples_repository(self, repository_folder:str):
1627
1636
  source=f"https://raw.githubusercontent.com/anionDev/CommonProjectStructureExamples/refs/heads/main/Other/Reference/RepositoryStructure.mdd"
1628
1637
  target=f"{repository_folder}/Other/Reference/RepositoryStructure.md"
1629
1638
  self.download_file(source,target)
1630
1639
 
1631
-
1632
- def update_dependent_oci_images(self,repo:str):
1640
+ @GeneralUtilities.check_arguments
1641
+ def update_dependent_oci_images(self, repo:str):
1633
1642
  self.oci_image_manager.update_default_tag_for_images_in_image_definitions_file(repo,True)
1643
+
1644
+ @GeneralUtilities.check_arguments
1645
+ def update_github_actions_image(self, repo_path: str, image_name: str, new_tag: str):
1646
+ """
1647
+ Updates the Docker image name + tag in .github/workflows/buildpipeline.yml
1648
+
1649
+ Args:
1650
+ repo_path (str): Path to repository root
1651
+ image_name (str): Docker image name (e.g. 'aniondev/scbuilder')
1652
+ new_tag (str): New tag (e.g. 'v1.2.3')
1653
+ """
1654
+
1655
+ workflow_file = Path(repo_path) / ".github" / "workflows" / "buildpipeline.yml"
1656
+ if not workflow_file.exists():
1657
+ raise FileNotFoundError(f"Workflow file not found: {workflow_file}")
1658
+ content = workflow_file.read_text(encoding="utf-8")
1659
+ escaped_image = re.escape(image_name)
1660
+ pattern = rf"({escaped_image}:)([^\s\"']+)"
1661
+ new_content, count = re.subn(
1662
+ pattern,
1663
+ rf"\1{new_tag}",
1664
+ content
1665
+ )
1666
+ if count == 0:
1667
+ raise ValueError(f"No matching image '{image_name}' found in workflow file.")
1668
+ workflow_file.write_text(new_content, encoding="utf-8")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.121
3
+ Version: 4.2.123
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=jh9l12XnMPmbQAcjBtw0Nk-OwMHuUCeqRGQyORuZVoU,205431
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=jcdW3vlDqBGbXWL6apkEyLDhl2E9vSaxZElWCEH6tAE,205530
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=TaSGXaDH4KWxN8Iv30m9zyitcaDYhEZVEPdKO3C3zfs,10712
@@ -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=xVPer8EGH5vhTT3_mpTMJJxWLB3aLxIcyTxKHODMbYg,22201
34
34
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=f0Uq1cA_4LvmL72cal0crrbKF6PcxL13D9wBKuQ1YBw,2328
35
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=Uz1yAls5yPa2u3bz0yYLk9rsdL37haZsPzy0b4F87T8,105366
35
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=PtYjrIDUtOIM7k6G5V-4DYqVNGNLw44y0u-4owDZbAY,106842
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
@@ -49,12 +49,12 @@ ScriptCollection/TFCPS/Maven/TFCPS_CodeUnitSpecific_Maven.py,sha256=WcWWtCV3GkAk
49
49
  ScriptCollection/TFCPS/Maven/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=57I7xbLtCtH-Edt1QKCSXF7wnGyAhbGMdghD_VFZIIY,13184
51
51
  ScriptCollection/TFCPS/NodeJS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
- ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=ufb3f7gnB40-OXsAcvPpoZlr1ZESWBfK0vHTdWCkmW8,14380
52
+ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK8sWPcn4D3eIE6gV9Oh7J37NBKjU089e-A,15852
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.121.dist-info/METADATA,sha256=lurlu-5Rn4Z_XDhMr7pw7o_vWsiJHGDpj6QgQBzi5PQ,7697
57
- scriptcollection-4.2.121.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
- scriptcollection-4.2.121.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
- scriptcollection-4.2.121.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
- scriptcollection-4.2.121.dist-info/RECORD,,
56
+ scriptcollection-4.2.123.dist-info/METADATA,sha256=qM6SKiEiWbsAiqVekIPRe1Hk9bRzEW_ts-GikpezFW4,7697
57
+ scriptcollection-4.2.123.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
+ scriptcollection-4.2.123.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
+ scriptcollection-4.2.123.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
+ scriptcollection-4.2.123.dist-info/RECORD,,