ScriptCollection 4.3.44__py3-none-any.whl → 4.3.46__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.
@@ -21,12 +21,11 @@ Caution: This script can cause harm if you pass a wrong inputfolder-argument.'''
21
21
 
22
22
  parser.add_argument('--printtableheadline', type=GeneralUtilities.string_to_boolean, const=True, default=True, nargs='?', help='Prints column-titles in the name-mapping-csv-file')
23
23
  parser.add_argument('--namemappingfile', default="NameMapping.csv", help='Specifies the file where the name-mapping will be written to')
24
- parser.add_argument('--extensions', default="exe,py,sh",
25
- help='Comma-separated list of file-extensions of files where this tool should be applied. Use "*" to obfuscate all')
24
+ parser.add_argument('--extensions', default="exe,py,sh", help='Comma-separated list of file-extensions of files where this tool should be applied. Use "*" to obfuscate all')
26
25
  parser.add_argument('--inputfolder', help='Specifies the foldere where the files are stored whose names should be obfuscated', required=True)
27
26
 
28
27
  args = parser.parse_args()
29
- ScriptCollectionCore().SCFilenameObfuscator(args.inputfolder, args.printtableheadline, args.namemappingfile, args.extensions)
28
+ ScriptCollectionCore().filenameObfuscator(args.inputfolder, args.printtableheadline, args.namemappingfile, args.extensions)
30
29
  return 0
31
30
 
32
31
 
@@ -41,7 +40,7 @@ This script does not process subfolders transitively.''')
41
40
  parser.add_argument('--extensions', default="exe,py,sh", help='Comma-separated list of file-extensions of files where this tool should be applied. Use "*" to obfuscate all')
42
41
  args = parser.parse_args()
43
42
 
44
- ScriptCollectionCore().SCCreateISOFileWithObfuscatedFiles(args.inputfolder, args.outputfile, args.printtableheadline, not args.createnoisofile, args.extensions)
43
+ ScriptCollectionCore().createISOFileWithObfuscatedFiles(args.inputfolder, args.outputfile, args.printtableheadline, not args.createnoisofile, args.extensions)
45
44
  return 0
46
45
 
47
46
 
@@ -49,7 +48,7 @@ def ChangeHashOfProgram() -> int:
49
48
  parser = argparse.ArgumentParser(description='Changes the hash-value of arbitrary files by appending data at the end of the file.')
50
49
  parser.add_argument('--inputfile', help='Specifies the script/executable-file whose hash-value should be changed', required=True)
51
50
  args = parser.parse_args()
52
- ScriptCollectionCore().SCChangeHashOfProgram(args.inputfile)
51
+ ScriptCollectionCore().changeHashOfProgram(args.inputfile)
53
52
  return 0
54
53
 
55
54
 
@@ -64,7 +63,7 @@ def CalculateBitcoinBlockHash() -> int:
64
63
  args = parser.parse_args()
65
64
 
66
65
  args = parser.parse_args()
67
- GeneralUtilities.write_message_to_stdout(ScriptCollectionCore().SCCalculateBitcoinBlockHash(args.version, args.previousblockhash, args.transactionsmerkleroot, args.timestamp, args.target, args.nonce))
66
+ GeneralUtilities.write_message_to_stdout(ScriptCollectionCore().calculateBitcoinBlockHash(args.version, args.previousblockhash, args.transactionsmerkleroot, args.timestamp, args.target, args.nonce))
68
67
  return 0
69
68
 
70
69
 
@@ -88,7 +87,7 @@ Hints:
88
87
  -30 is the commonly used value for the period""")
89
88
  parser.add_argument('csvfile', help='File where the 2fa-codes are stored')
90
89
  args = parser.parse_args()
91
- ScriptCollectionCore().SCShow2FAAsQRCode(args.csvfile)
90
+ ScriptCollectionCore().show2FAAsQRCode(args.csvfile)
92
91
  return 0
93
92
 
94
93
 
@@ -100,7 +99,7 @@ This program prints all files where the given searchstring was found to the cons
100
99
  parser.add_argument('searchstring', help='string to look for')
101
100
 
102
101
  args = parser.parse_args()
103
- ScriptCollectionCore().SCSearchInFiles(args.folder, args.searchstring)
102
+ ScriptCollectionCore().searchInFiles(args.folder, args.searchstring)
104
103
  return 0
105
104
 
106
105
 
@@ -115,7 +114,7 @@ def ReplaceSubstringsInFilenames() -> int:
115
114
 
116
115
  args = parser.parse_args()
117
116
 
118
- ScriptCollectionCore().SCReplaceSubstringsInFilenames(args.folder, args.substringInFilename, args.newSubstringInFilename, args.conflictResolveMode)
117
+ ScriptCollectionCore().replaceSubstringsInFilenames(args.folder, args.substringInFilename, args.newSubstringInFilename, args.conflictResolveMode)
119
118
  return 0
120
119
 
121
120
 
@@ -126,7 +125,7 @@ def GenerateSnkFiles() -> int:
126
125
  parser.add_argument('--amountofkeys', default='10')
127
126
 
128
127
  args = parser.parse_args()
129
- ScriptCollectionCore().SCGenerateSnkFiles(args.outputfolder, args.keysize, args.amountofkeys)
128
+ ScriptCollectionCore().generateSnkFiles(args.outputfolder, args.keysize, args.amountofkeys)
130
129
  return 0
131
130
 
132
131
 
@@ -142,14 +141,15 @@ def OrganizeLinesInFile() -> int:
142
141
  parser.add_argument('--ignored_start_character', default="", help='Characters which should not be considered at the begin of a line')
143
142
 
144
143
  args = parser.parse_args()
145
- ScriptCollectionCore().sc_organize_lines_in_file(args.file, args.encoding, args.sort, args.remove_duplicated_lines, args.ignore_first_line, args.remove_empty_lines, list(args.ignored_start_character))
144
+ ScriptCollectionCore().organize_lines_in_file(args.file, args.encoding, args.sort, args.remove_duplicated_lines, args.ignore_first_line, args.remove_empty_lines, list(args.ignored_start_character))
146
145
 
147
146
 
148
- def CreateHashOfAllFiles() -> int:
147
+ def CreateHashOfFolder() -> int:
149
148
  parser = argparse.ArgumentParser(description='Calculates the SHA-256-value of all files in the given folder and stores the hash-value in a file next to the hashed file.')
150
- parser.add_argument('folder', help='Folder where the files are stored which should be hashed')
149
+ parser.add_argument('folder', default=".", help='Folder where the files are stored which should be hashed')
151
150
  args = parser.parse_args()
152
- ScriptCollectionCore().SCCreateHashOfAllFiles(args.folder)
151
+ folder:str=GeneralUtilities.resolve_relative_path(args.folder,os.getcwd())
152
+ ScriptCollectionCore().create_hash_of_folder(folder)
153
153
  return 0
154
154
 
155
155
 
@@ -163,7 +163,7 @@ def CreateSimpleMergeWithoutRelease() -> int:
163
163
  parser.add_argument('--no-remove-sourcebranch', dest='removesourcebranch', action='store_false', help='TODO')
164
164
  parser.set_defaults(removesourcebranch=False)
165
165
  args = parser.parse_args()
166
- ScriptCollectionCore().SCCreateSimpleMergeWithoutRelease(args.repository, args.sourcebranch, args.targetbranch, args.remotename, args.removesourcebranch)
166
+ ScriptCollectionCore().createSimpleMergeWithoutRelease(args.repository, args.sourcebranch, args.targetbranch, args.remotename, args.removesourcebranch)
167
167
  return 0
168
168
 
169
169
 
@@ -172,7 +172,7 @@ def CreateEmptyFileWithSpecificSize() -> int:
172
172
  parser.add_argument('name', help='Specifies the name of the created file')
173
173
  parser.add_argument('size', help='Specifies the size of the created file')
174
174
  args = parser.parse_args()
175
- return ScriptCollectionCore().SCCreateEmptyFileWithSpecificSize(args.name, args.size)
175
+ return ScriptCollectionCore().createEmptyFileWithSpecificSize(args.name, args.size)
176
176
 
177
177
 
178
178
  def ShowMissingFiles() -> int:
@@ -241,17 +241,10 @@ Caution: This script can cause harm if you pass a wrong inputfolder-argument.'''
241
241
  parser.add_argument('--inputfolder', help='Specifies the folder where the files are stored whose names should be obfuscated', required=True)
242
242
 
243
243
  args = parser.parse_args()
244
- ScriptCollectionCore().SCObfuscateFilesFolder(args.inputfolder, args.printtableheadline, args.namemappingfile, args.extensions)
244
+ ScriptCollectionCore().obfuscateFilesFolder(args.inputfolder, args.printtableheadline, args.namemappingfile, args.extensions)
245
245
  return 0
246
246
 
247
247
 
248
- def HealthCheck() -> int:
249
- parser = argparse.ArgumentParser()
250
- parser.add_argument('--file', required=True)
251
- args = parser.parse_args()
252
- return ScriptCollectionCore().SCHealthcheck(args.file)
253
-
254
-
255
248
  def BuildCodeUnits() -> int:
256
249
  parser = argparse.ArgumentParser()
257
250
 
@@ -264,18 +257,18 @@ def BuildCodeUnits() -> int:
264
257
  parser.add_argument('-p','--ispremerge', required=False, default=False, action='store_true')
265
258
  parser.add_argument('-u','--assertnonewchanges', required=False, default=False, action='store_true')
266
259
  parser.add_argument('-m','--addreadytomergeflag', required=False, default=False, action='store_true')
267
-
260
+ parser.add_argument('-c','--runincontainer', required=False, default=False, action='store_true')
268
261
  args = parser.parse_args()
269
262
 
270
263
  verbosity=LogLevel(int(args.verbosity))
271
-
272
264
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
273
-
274
265
  t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge,args.assertnonewchanges,args.addreadytomergeflag)
275
- t.build_codeunits()
266
+ if args.runincontainer:
267
+ t.build_codeunits_in_container(repo)
268
+ else:
269
+ t.build_codeunits()
276
270
  return 0
277
271
 
278
-
279
272
  def BuildCodeUnitsC() -> int:
280
273
  parser = argparse.ArgumentParser()
281
274
  parser.add_argument('-r','--repositoryfolder', required=False, default=".")
@@ -290,6 +283,7 @@ def BuildCodeUnitsC() -> int:
290
283
  parser.add_argument('-u','--assertnonewchanges', required=False, default=False, action='store_true')
291
284
  parser.add_argument('-m','--addreadytomergeflag', required=False, default=False, action='store_true')
292
285
  args = parser.parse_args()
286
+
293
287
  GeneralUtilities.reconfigure_standard_input_and_outputs()
294
288
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
295
289
  verbosity=LogLevel(int(args.verbosity))
@@ -309,6 +303,7 @@ def UpdateDependencies() -> int:
309
303
  parser.add_argument('--additionalargumentsfile', required=False, default=None)
310
304
  parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
311
305
  args = parser.parse_args()
306
+
312
307
  verbosity=LogLevel(int(args.verbosity))
313
308
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
314
309
  t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,False,False)
@@ -327,6 +322,7 @@ def GenerateCertificateAuthority() -> int:
327
322
  parser.add_argument('--days_until_expire', required=False, default=None, type=int)
328
323
  parser.add_argument('--password', required=False, default=None)
329
324
  args = parser.parse_args()
325
+
330
326
  ScriptCollectionCore().generate_certificate_authority(os.getcwd(), args.name, args.subj_c, args.subj_st, args.subj_l, args.subj_o, args.subj_ou, args.days_until_expire, args.password)
331
327
  return 0
332
328
 
@@ -1174,26 +1170,14 @@ def SearchForSecrets() -> int:
1174
1170
  t.search_for_secrets()
1175
1171
  return 0
1176
1172
 
1177
-
1178
- def __prepare_build_pipeline(verbosity: int) -> None:
1179
- # Common preparation for the build-pipeline. The actual buildx-build (see TFCPS_CodeUnitSpecific_Docker.build)
1180
- # exports the image via "--output type=docker,dest=...tar". The default "docker"-driver can not do that unless
1181
- # the containerd-image-store is enabled on the daemon, so a "docker-container"-builder is created and selected
1182
- # here. This is required for GitLab and GitHub (and any other CI) alike, so both entry-points share this logic.
1183
- sc: ScriptCollectionCore = ScriptCollectionCore()
1184
- sc.log.loglevel = LogLevel(verbosity)
1185
- GeneralUtilities.assert_condition(sc.is_running_in_build_container(), "This function should only be run in the build container.")
1186
- sc.run_program("update-ca-certificates")
1187
- sc.run_program_argsasarray("sh",["-c","docker buildx create --name ci-builder --driver docker-container --use 2>/dev/null || docker buildx use ci-builder"])
1188
- sc.run_program("docker","buildx inspect --bootstrap")
1189
-
1190
-
1191
1173
  def PrepareBuildPipelineForGitlab() -> int:
1192
1174
  parser = argparse.ArgumentParser(description="Prepares the build-pipeline-configuration for GitLab.")
1193
1175
  verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
1194
1176
  parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
1195
1177
  args = parser.parse_args()
1196
- __prepare_build_pipeline(int(args.verbosity))
1178
+ sc=ScriptCollectionCore()
1179
+ sc.log.loglevel=LogLevel(int(args.verbosity))
1180
+ sc.prepare_build_pipeline_for_gitlab()
1197
1181
  return 0
1198
1182
 
1199
1183
 
@@ -1202,7 +1186,9 @@ def PrepareBuildPipelineForGithub() -> int:
1202
1186
  verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
1203
1187
  parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
1204
1188
  args = parser.parse_args()
1205
- __prepare_build_pipeline(int(args.verbosity))
1189
+ sc=ScriptCollectionCore()
1190
+ sc.log.loglevel=LogLevel(int(args.verbosity))
1191
+ sc.prepare_build_pipeline_for_github()
1206
1192
  return 0
1207
1193
 
1208
1194
 
@@ -33,12 +33,13 @@ import qrcode
33
33
  import pycdlib
34
34
  import send2trash
35
35
  from pypdf import PdfReader, PdfWriter
36
+ from packaging.version import Version
36
37
  from .GeneralUtilities import GeneralUtilities,Platform
37
38
  from .ProgramRunnerBase import ProgramRunnerBase
38
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
40
  from .SCLog import SCLog, LogLevel
40
41
 
41
- version = "4.3.44"
42
+ version = "4.3.46"
42
43
  __version__ = version
43
44
 
44
45
  class VSCodeWorkspaceShellTask:
@@ -1000,6 +1001,12 @@ class ScriptCollectionCore:
1000
1001
  result = self.run_program_argsasarray("git", ["rev-parse", "--abbrev-ref", "HEAD"], repository, throw_exception_if_exitcode_is_not_zero=True)
1001
1002
  return result[1].replace("\r", GeneralUtilities.empty_string).replace("\n", GeneralUtilities.empty_string)
1002
1003
 
1004
+ @GeneralUtilities.check_arguments
1005
+ def git_set_local_configuration_value(self, repository: str, key: str, value: str) -> None:
1006
+ """Sets a git-configuration-value in the local configuration of the given repository (does not modify the global or system configuration)."""
1007
+ self.assert_is_git_repository(repository)
1008
+ self.run_program_argsasarray("git", ["config", "--local", key, value], repository, throw_exception_if_exitcode_is_not_zero=True)
1009
+
1003
1010
  @GeneralUtilities.check_arguments
1004
1011
  def git_get_commitid_of_tag(self, repository: str, tag: str) -> str:
1005
1012
  self.is_git_or_bare_git_repository(repository)
@@ -1601,7 +1608,7 @@ class ScriptCollectionCore:
1601
1608
  GeneralUtilities.write_message_to_stdout(file)
1602
1609
 
1603
1610
  @GeneralUtilities.check_arguments
1604
- def SCCreateEmptyFileWithSpecificSize(self, name: str, size_string: str) -> int:
1611
+ def createEmptyFileWithSpecificSize(self, name: str, size_string: str) -> int:
1605
1612
  if size_string.isdigit():
1606
1613
  size = int(size_string)
1607
1614
  else:
@@ -1630,13 +1637,23 @@ class ScriptCollectionCore:
1630
1637
  return 0
1631
1638
 
1632
1639
  @GeneralUtilities.check_arguments
1633
- def SCCreateHashOfAllFiles(self, folder: str) -> None:
1634
- for file in GeneralUtilities.absolute_file_paths(folder):
1635
- with open(file+".sha256", "w+", encoding="utf-8") as f:
1636
- f.write(GeneralUtilities.get_sha256_of_file(file))
1640
+ def create_hash_of_folder(self, folder: str) -> str:
1641
+ hasher = hashlib.sha256()
1642
+ hasher.update(os.path.basename(folder).encode())
1643
+ root = Path(folder)
1644
+
1645
+ for file in sorted(root.rglob("*")):
1646
+ if file.is_file():
1647
+ relative_path =GeneralUtilities.normalize_path(file.relative_to(root).as_posix())
1648
+ hasher.update(relative_path.encode())
1649
+ with file.open("rb") as f:
1650
+ while chunk := f.read(8192):
1651
+ hasher.update(chunk)
1652
+
1653
+ return hasher.hexdigest()
1637
1654
 
1638
1655
  @GeneralUtilities.check_arguments
1639
- def SCCreateSimpleMergeWithoutRelease(self, repository: str, sourcebranch: str, targetbranch: str, remotename: str, remove_source_branch: bool) -> None:
1656
+ def createSimpleMergeWithoutRelease(self, repository: str, sourcebranch: str, targetbranch: str, remotename: str, remove_source_branch: bool) -> None:
1640
1657
  commitid = self.git_merge(repository, sourcebranch, targetbranch, False, True)
1641
1658
  self.git_merge(repository, targetbranch, sourcebranch, True, True)
1642
1659
  created_version = self.get_semver_version(repository)
@@ -1648,7 +1665,7 @@ class ScriptCollectionCore:
1648
1665
  self.git_remove_branch(repository, sourcebranch)
1649
1666
 
1650
1667
  @GeneralUtilities.check_arguments
1651
- def sc_organize_lines_in_file(self, file: str, encoding: str="utf-8", sort: bool = False, remove_duplicated_lines: bool = False, ignore_first_line: bool = False, remove_empty_lines: bool = True, ignored_start_character: list = list()):
1668
+ def organize_lines_in_file(self, file: str, encoding: str="utf-8", sort: bool = False, remove_duplicated_lines: bool = False, ignore_first_line: bool = False, remove_empty_lines: bool = True, ignored_start_character: list = list()):
1652
1669
  GeneralUtilities.assert_file_exists(file)
1653
1670
 
1654
1671
  # read file
@@ -1692,7 +1709,7 @@ class ScriptCollectionCore:
1692
1709
  return result
1693
1710
 
1694
1711
  @GeneralUtilities.check_arguments
1695
- def SCGenerateSnkFiles(self, outputfolder, keysize=4096, amountofkeys=10) -> int:
1712
+ def generateSnkFiles(self, outputfolder, keysize=4096, amountofkeys=10) -> int:
1696
1713
  GeneralUtilities.ensure_directory_exists(outputfolder)
1697
1714
  for _ in range(amountofkeys):
1698
1715
  file = os.path.join(outputfolder, str(uuid.uuid4())+".snk")
@@ -1733,7 +1750,7 @@ class ScriptCollectionCore:
1733
1750
  os.rename(file, new_filename)
1734
1751
 
1735
1752
  @GeneralUtilities.check_arguments
1736
- def SCReplaceSubstringsInFilenames(self, folder: str, substringInFilename: str, newSubstringInFilename: str, conflictResolveMode: str) -> None:
1753
+ def replaceSubstringsInFilenames(self, folder: str, substringInFilename: str, newSubstringInFilename: str, conflictResolveMode: str) -> None:
1737
1754
  for file in GeneralUtilities.absolute_file_paths(folder):
1738
1755
  self.__process_file(file, substringInFilename, newSubstringInFilename, conflictResolveMode)
1739
1756
 
@@ -1753,7 +1770,7 @@ class ScriptCollectionCore:
1753
1770
  GeneralUtilities.write_message_to_stdout(file)
1754
1771
 
1755
1772
  @GeneralUtilities.check_arguments
1756
- def SCSearchInFiles(self, folder: str, searchstring: str) -> None:
1773
+ def searchInFiles(self, folder: str, searchstring: str) -> None:
1757
1774
  for file in GeneralUtilities.absolute_file_paths(folder):
1758
1775
  self.__check_file(file, searchstring)
1759
1776
 
@@ -1774,7 +1791,7 @@ class ScriptCollectionCore:
1774
1791
  GeneralUtilities.write_message_to_stdout(self.get_string_as_qr_code(qrcode_content))
1775
1792
 
1776
1793
  @GeneralUtilities.check_arguments
1777
- def SCShow2FAAsQRCode(self, csvfile: str) -> None:
1794
+ def show2FAAsQRCode(self, csvfile: str) -> None:
1778
1795
  lines = GeneralUtilities.read_csv_file(csvfile, True)
1779
1796
  lines.sort(key=lambda items: ''.join(items).lower())
1780
1797
  for line in lines:
@@ -1782,7 +1799,7 @@ class ScriptCollectionCore:
1782
1799
  GeneralUtilities.write_message_to_stdout(GeneralUtilities.get_longline())
1783
1800
 
1784
1801
  @GeneralUtilities.check_arguments
1785
- def SCCalculateBitcoinBlockHash(self, block_version_number: str, previousblockhash: str, transactionsmerkleroot: str, timestamp: str, target: str, nonce: str) -> str:
1802
+ def calculateBitcoinBlockHash(self, block_version_number: str, previousblockhash: str, transactionsmerkleroot: str, timestamp: str, target: str, nonce: str) -> str:
1786
1803
  # Example-values:
1787
1804
  # block_version_number: "00000020"
1788
1805
  # previousblockhash: "66720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab61000000000000000000"
@@ -1794,7 +1811,7 @@ class ScriptCollectionCore:
1794
1811
  return binascii.hexlify(hashlib.sha256(hashlib.sha256(binascii.unhexlify(header)).digest()).digest()[::-1]).decode('utf-8')
1795
1812
 
1796
1813
  @GeneralUtilities.check_arguments
1797
- def SCChangeHashOfProgram(self, inputfile: str) -> None:
1814
+ def changeHashOfProgram(self, inputfile: str) -> None:
1798
1815
  valuetoappend = str(uuid.uuid4())
1799
1816
 
1800
1817
  outputfile = inputfile + '.modified'
@@ -1840,12 +1857,12 @@ class ScriptCollectionCore:
1840
1857
  iso.close()
1841
1858
 
1842
1859
  @GeneralUtilities.check_arguments
1843
- def SCCreateISOFileWithObfuscatedFiles(self, inputfolder: str, outputfile: str, printtableheadline, createisofile, extensions) -> None:
1860
+ def createISOFileWithObfuscatedFiles(self, inputfolder: str, outputfile: str, printtableheadline, createisofile, extensions) -> None:
1844
1861
  if (os.path.isdir(inputfolder)):
1845
1862
  namemappingfile = "name_map.csv"
1846
1863
  files_directory = inputfolder
1847
1864
  files_directory_obf = f"{files_directory}_Obfuscated"
1848
- self.SCObfuscateFilesFolder(
1865
+ self.obfuscateFilesFolder(
1849
1866
  inputfolder, printtableheadline, namemappingfile, extensions)
1850
1867
  os.rename(namemappingfile, os.path.join(
1851
1868
  files_directory_obf, namemappingfile))
@@ -1856,7 +1873,7 @@ class ScriptCollectionCore:
1856
1873
  raise ValueError(f"Directory not found: '{inputfolder}'")
1857
1874
 
1858
1875
  @GeneralUtilities.check_arguments
1859
- def SCFilenameObfuscator(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1876
+ def filenameObfuscator(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1860
1877
  obfuscate_all_files = extensions == "*"
1861
1878
  if (obfuscate_all_files):
1862
1879
  obfuscate_file_extensions = None
@@ -1894,22 +1911,9 @@ class ScriptCollectionCore:
1894
1911
  return True
1895
1912
  return False
1896
1913
 
1897
- @GeneralUtilities.check_arguments
1898
- def SCHealthcheck(self, file: str) -> int:
1899
- lines = GeneralUtilities.read_lines_from_file(file)
1900
- for line in reversed(lines):
1901
- if not GeneralUtilities.string_is_none_or_whitespace(line):
1902
- if "RunningHealthy (" in line: # TODO use regex
1903
- GeneralUtilities.write_message_to_stderr(f"Healthy running due to line '{line}' in file '{file}'.")
1904
- return 0
1905
- else:
1906
- GeneralUtilities.write_message_to_stderr(f"Not healthy running due to line '{line}' in file '{file}'.")
1907
- return 1
1908
- GeneralUtilities.write_message_to_stderr(f"No valid line found for healthycheck in file '{file}'.")
1909
- return 2
1910
1914
 
1911
1915
  @GeneralUtilities.check_arguments
1912
- def SCObfuscateFilesFolder(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1916
+ def obfuscateFilesFolder(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1913
1917
  obfuscate_all_files = extensions == "*"
1914
1918
  if (obfuscate_all_files):
1915
1919
  obfuscate_file_extensions = None
@@ -1924,10 +1928,10 @@ class ScriptCollectionCore:
1924
1928
  if (os.path.isdir(inputfolder)):
1925
1929
  for file in GeneralUtilities.absolute_file_paths(inputfolder):
1926
1930
  if obfuscate_all_files or self.__extension_matchs(file, obfuscate_file_extensions):
1927
- self.SCChangeHashOfProgram(file)
1931
+ self.changeHashOfProgram(file)
1928
1932
  os.remove(file)
1929
1933
  os.rename(file + ".modified", file)
1930
- self.SCFilenameObfuscator(inputfolder, printtableheadline, namemappingfile, extensions)
1934
+ self.filenameObfuscator(inputfolder, printtableheadline, namemappingfile, extensions)
1931
1935
  else:
1932
1936
  raise ValueError(f"Directory not found: '{inputfolder}'")
1933
1937
 
@@ -4160,3 +4164,52 @@ OCR-content:
4160
4164
  def is_running_in_build_container(self) ->bool:
4161
4165
  """this function is based on a convention and does not do a real check."""
4162
4166
  return os.environ.get("ISRUNNINGINBUILDCONTAINER") == "true"
4167
+
4168
+ def prepare_build_pipeline_for_gitlab(self):
4169
+ repository_folder:str=os.getcwd()
4170
+ self.__prepare_build_pipeline(repository_folder)
4171
+
4172
+ def prepare_build_pipeline_for_github(self):
4173
+ repository_folder:str=os.getcwd()
4174
+ self.assert_scbuilder_image_in_github_workflow_matches_image_definition(repository_folder)
4175
+ self.__prepare_build_pipeline(repository_folder)
4176
+
4177
+ def __prepare_build_pipeline(self,repository_folder:str) -> None:
4178
+ GeneralUtilities.assert_condition(self.is_running_in_build_container(), "This function should only be run in the build container.")
4179
+
4180
+ expected_image = self.__get_scbuilder_image_from_image_definition_file(repository_folder)
4181
+ minimal_required_scbuilder_version = Version("1.2.5")#the preparation-steps below require at least this SCBuilder-version
4182
+ defined_scbuilder_version = self.__get_version_of_scbuilder_image(expected_image)#TODO remove this check after 2026-12-31
4183
+ GeneralUtilities.assert_condition(defined_scbuilder_version >= minimal_required_scbuilder_version, f"The SCBuilder-version {defined_scbuilder_version} defined in the image-definition-file of the repository is older than the minimal required version {minimal_required_scbuilder_version}. Please update the SCBuilder-image.")
4184
+
4185
+ self.run_program("update-ca-certificates")
4186
+ self.run_program_argsasarray("sh",["-c","docker buildx create --name ci-builder --driver docker-container --use 2>/dev/null || docker buildx use ci-builder"])
4187
+ self.run_program("docker","buildx inspect --bootstrap")
4188
+
4189
+ @GeneralUtilities.check_arguments
4190
+ def assert_scbuilder_image_in_github_workflow_matches_image_definition(self, repository: str) -> None:
4191
+ """Asserts that the SCBuilder-image used in the GitHub-buildpipeline is the same as the one defined in the image-definition-file of the repository."""
4192
+ workflow_file = os.path.join(repository, ".github", "workflows", "buildpipeline.yml")
4193
+ GeneralUtilities.assert_file_exists(workflow_file, f"The file '{workflow_file}' does not exist.")
4194
+ expected_image = self.__get_scbuilder_image_from_image_definition_file(repository)
4195
+ used_images = re.findall(r"^\s*image:\s*[\"']?(\S*scbuilder:\S+?)[\"']?\s*$", GeneralUtilities.read_text_from_file(workflow_file), re.IGNORECASE | re.MULTILINE)
4196
+ GeneralUtilities.assert_condition(1==len(used_images), f"No SCBuilder-image found in '{workflow_file}'.")
4197
+ used_image = used_images[0]
4198
+ GeneralUtilities.assert_condition(used_image == expected_image, f"The SCBuilder-image '{used_image}' used in '{workflow_file}' does not match the image '{expected_image}' defined in the image-definition-file of the repository.")
4199
+
4200
+ @GeneralUtilities.check_arguments
4201
+ def __get_version_of_scbuilder_image(self, image: str) -> Version:
4202
+ """Returns the version of a SCBuilder-image-address including tag (example: "aniondev/scbuilder:v1.2.5" results in the version 1.2.5)."""
4203
+ version_match = re.search(r"\d+(\.\d+)+", image.split(":")[-1])
4204
+ GeneralUtilities.assert_condition(version_match is not None, f"The SCBuilder-image '{image}' does not contain a version-string.")
4205
+ return Version(version_match.group(0))
4206
+
4207
+ @GeneralUtilities.check_arguments
4208
+ def __get_scbuilder_image_from_image_definition_file(self, repository: str) -> str:
4209
+ """Returns the SCBuilder-image (address including tag) as defined in the image-definition-file of the repository."""
4210
+ image_definition_file = os.path.join(repository, ".ScriptCollection", "OCIImages", "ImageDefinition.csv")
4211
+ GeneralUtilities.assert_file_exists(image_definition_file, f"The file '{image_definition_file}' does not exist.")
4212
+ for line in [line.split(";") for line in GeneralUtilities.read_nonempty_lines_from_file(image_definition_file)[1:]]:#the first line is the header-line
4213
+ if line[0].lower() == "scbuilder":
4214
+ return f"{line[1]}:{line[2]}"
4215
+ raise ValueError(f"No SCBuilder-image defined in '{image_definition_file}'.")
@@ -347,6 +347,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
347
347
  @GeneralUtilities.check_arguments
348
348
  def do_common_tasks(self,current_codeunit_version:str,certificateGeneratorInformation:CertificateGeneratorInformationBase)-> None:
349
349
  self.do_common_tasks_base(current_codeunit_version)
350
+ self.update_year_for_dotnet_codeunit()
350
351
  codeunit_name =self.get_codeunit_name()
351
352
  codeunit_version = self.tfcps_Tools_General.get_version_of_project(self.get_repository_folder()) # Should always be the same as the project-version #TODO make this configurable from outside
352
353
  folder_of_current_file =os.path.join(self.get_codeunit_folder(),"Other")
@@ -680,7 +681,6 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
680
681
 
681
682
  def set_dependency_version(self,name:str,new_version:str)->None:
682
683
  raise ValueError(f"Operation is not implemented.")
683
- #self.update_year_for_dotnet_codeunit()
684
684
  #csproj_file:str=os.path.join(self.get_codeunit_folder(), self.get_codeunit_name(), self.get_codeunit_name() + ".csproj")
685
685
  #self._protected_sc.update_dependencies_of_dotnet_project(csproj_file,[])#TODO set ignored codeunits
686
686
 
@@ -62,6 +62,9 @@ class TFCPS_CodeUnit_BuildCodeUnits:
62
62
  if self.is_pre_merge():
63
63
  GeneralUtilities.assert_condition(not self.__assert_no_new_changes,f"A pre-merge build can not be done with the assert-no-new-changes-option.")
64
64
 
65
+ #disable autocrlf for this repository so git does not rewrite line-endings on checkout/commit. otherwise the line-endings normalized by __normalize_line_endings_of_common_files would be converted back to crlf, which results in spurious uncommitted changes (and therefore in failing assert-no-new-changes-builds) on windows.
66
+ self.sc.git_set_local_configuration_value(self.repository, "core.autocrlf", "false")
67
+
65
68
 
66
69
  #ensure <repo>/.ScriptCollection/.gitignore is set up (ignores the cache-folder so cache-files never show up as uncommitted changes)
67
70
  self.sc.ensure_scriptcollection_gitignore_is_setup(self.repository)
@@ -131,11 +134,25 @@ class TFCPS_CodeUnit_BuildCodeUnits:
131
134
 
132
135
  if self.__assert_no_new_changes:
133
136
  self.sc.assert_no_uncommitted_changes(self.repository,"There are new uncommitted changes in the repository.")
137
+
138
+ self.__log_hashes_of_artifacts(codeunits)
139
+
134
140
  end_time:datetime=GeneralUtilities.get_now()
135
141
  duration=end_time-start_time
136
142
  self.sc.log.log(f"Finished building codeunits at {GeneralUtilities.datetime_to_string_for_readable_entry(end_time,False)}. (Duration: {GeneralUtilities.timedelta_to_simple_string(duration)})")
137
143
  self.sc.log.log(GeneralUtilities.get_line())
138
144
 
145
+ @GeneralUtilities.check_arguments
146
+ def __log_hashes_of_artifacts(self, codeunits:list[str]) -> None:
147
+ self.sc.log.log("Hashes of the artifacts of the codeunits:")
148
+ for codeunit_name in codeunits:
149
+ artifacts_folder = os.path.join(self.repository, codeunit_name, "Other", "Artifacts")
150
+ if os.path.isdir(artifacts_folder):
151
+ hash_of_artifacts:str = self.sc.create_hash_of_folder(artifacts_folder)
152
+ self.sc.log.log(f" - {codeunit_name}: {hash_of_artifacts}")
153
+ else:
154
+ self.sc.log.log(f" - {codeunit_name}: (no artifacts-folder available)")
155
+
139
156
  @GeneralUtilities.check_arguments
140
157
  def __normalize_line_endings_of_common_files(self) -> None:
141
158
  #TODO add option to define exceptions (means: files which should not be normalized).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.44
3
+ Version: 4.3.46
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
@@ -1,6 +1,6 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=GP-jnb1GbvT8jzlH-cqnxgOzBzeUdiaWnDXtKNjsxiA,12153
2
2
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
3
- ScriptCollection/Executables.py,sha256=uTdjo_XKTF6L9Xx_HgrnsE4kNP3ahcNR9PCuFuWcJPc,67909
3
+ ScriptCollection/Executables.py,sha256=7HPkyAqil8G0WO7kukInq0ineI9Gq3PnV4BYfVlOsQA,67063
4
4
  ScriptCollection/GeneralUtilities.py,sha256=qYhrKkwbEewGIppuxYRmGhLP50C443tw7sBlwH7Mkbc,71606
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=yYaC95h40uszuZPggn2kK3qXIN2ZjGMCavo-NQ53ElQ,1537
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
12
- ScriptCollection/ScriptCollectionCore.py,sha256=V1RvlghyoGQOzb4Gp7dlElRQycqWhiyifWj7t13l92M,242342
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=vHxXBcT-LKI00_N54OK4wWMsNm7T84Zsrp5ENTkEvqM,246508
13
13
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
14
14
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
@@ -35,7 +35,7 @@ ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz
35
35
  ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-cHU4LQttS7XNT60,11272
36
36
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=H9FWlS6BPK-UWJXdWN686ePky4Hq-Q13T0Kx8HSJu7s,34990
37
37
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Ll5EOkpVpPiFrM2mLeQXolaF7075IwgtnHXvfdpkH4k,9904
38
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=tm6JkAKYIc-VA-0xyrMUxrvnoh0J-tTLTGlRmWBWaU0,31153
38
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=ufnDoe_YIMGlB-kyW_1mOKXUOl93PdmkktcjLneoB_s,32292
39
39
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
40
40
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
41
41
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=zp7n0Li7GTi4tERDMgDcJ-o3m6131m31zvkat0lALEc,7781
@@ -49,7 +49,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
49
49
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
50
50
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
51
51
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
52
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=7A1KacqFXZKGWq3p8wW3OfxRNSiSQ0L7K4gLOajinuY,46588
52
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=X-yrZJBE3EvN4hciPeWZ9jkLs8dOXzNyriMUT1-GFk8,46587
53
53
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=d8U-sIhsneMplYkG73BJRQQZh4uLoX7QiOhbnZNuOM8,8540
55
55
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -63,8 +63,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
63
63
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
65
65
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
- scriptcollection-4.3.44.dist-info/METADATA,sha256=VubjpLSJ_0IohEKn3JD5Vz1O9obZpPC7tC9yXI8P9Q4,7648
67
- scriptcollection-4.3.44.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
- scriptcollection-4.3.44.dist-info/entry_points.txt,sha256=Iq9YMSTWNCAJpBzM5L9CQx80tL9-XUu6MzDRAdBrIPg,5875
69
- scriptcollection-4.3.44.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
- scriptcollection-4.3.44.dist-info/RECORD,,
66
+ scriptcollection-4.3.46.dist-info/METADATA,sha256=CEzicWf-ylGhyuAkBXLTWkLRHpcWMg0tRpeCmzBagRQ,7648
67
+ scriptcollection-4.3.46.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
+ scriptcollection-4.3.46.dist-info/entry_points.txt,sha256=xWOFHGufgef8jsKQ3c2pFBfM_hjweFXuxfKmghQs-VI,5814
69
+ scriptcollection-4.3.46.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
+ scriptcollection-4.3.46.dist-info/RECORD,,
@@ -14,7 +14,7 @@ sccreatechangelogentry = ScriptCollection.Executables:CreateChangelogEntry
14
14
  sccreateemptyfilewithspecificsize = ScriptCollection.Executables:CreateEmptyFileWithSpecificSize
15
15
  sccreatefile = ScriptCollection.Executables:CreateFile
16
16
  sccreatefolder = ScriptCollection.Executables:CreateFolder
17
- sccreatehashofallfiles = ScriptCollection.Executables:CreateHashOfAllFiles
17
+ sccreatehashoffolder = ScriptCollection.Executables:CreateHashOfFolder
18
18
  sccreateisofilewithobfuscatedfiles = ScriptCollection.Executables:CreateISOFileWithObfuscatedFiles
19
19
  sccreaterelease = ScriptCollection.Executables:CreateRelease
20
20
  sccreatesimplemergewithoutrelease = ScriptCollection.Executables:CreateSimpleMergeWithoutRelease
@@ -39,7 +39,6 @@ scgeneratesnkfiles = ScriptCollection.Executables:GenerateSnkFiles
39
39
  scgeneratetaskfilefromworkspacefile = ScriptCollection.Executables:GenerateTaskfileFromWorkspacefile
40
40
  scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
41
41
  scgetsize = ScriptCollection.Executables:GetSize
42
- schealthcheck = ScriptCollection.Executables:Healthcheck
43
42
  sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
44
43
  sclistfoldercontent = ScriptCollection.Executables:ListFolderContent
45
44
  scloc = ScriptCollection.Executables:LOC