ScriptCollection 4.2.122__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.122"
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.122
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=DAjGRovCeOBIYzPmaSNnjAOilXai0_qa-nvQejawnhk,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
@@ -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.122.dist-info/METADATA,sha256=0Ea9B2vFPEoHo8C-X6V6LSWYugYsBppNxmmbx-iiJMs,7697
57
- scriptcollection-4.2.122.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
- scriptcollection-4.2.122.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
- scriptcollection-4.2.122.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
- scriptcollection-4.2.122.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,,