ScriptCollection 3.5.53__py3-none-any.whl → 3.5.54__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.
- ScriptCollection/GeneralUtilities.py +0 -36
- ScriptCollection/ProgramRunnerBase.py +10 -5
- ScriptCollection/ProgramRunnerEpew.py +14 -10
- ScriptCollection/ProgramRunnerPopen.py +4 -0
- ScriptCollection/ScriptCollectionCore.py +68 -28
- ScriptCollection/TasksForCommonProjectStructure.py +80 -83
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.54.dist-info}/METADATA +2 -2
- ScriptCollection-3.5.54.dist-info/RECORD +16 -0
- ScriptCollection-3.5.53.dist-info/RECORD +0 -16
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.54.dist-info}/WHEEL +0 -0
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.54.dist-info}/entry_points.txt +0 -0
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.54.dist-info}/top_level.txt +0 -0
|
@@ -910,42 +910,6 @@ class GeneralUtilities:
|
|
|
910
910
|
exit_code = process.wait()
|
|
911
911
|
return (exit_code, stdout, stderr)
|
|
912
912
|
|
|
913
|
-
@staticmethod
|
|
914
|
-
@check_arguments
|
|
915
|
-
def is_file(path: str) -> bool:
|
|
916
|
-
exit_code, _, stderr = GeneralUtilities.run_program_simple("scfileexists", ["--path", path])
|
|
917
|
-
if exit_code == 0:
|
|
918
|
-
return True
|
|
919
|
-
elif exit_code == 1:
|
|
920
|
-
raise ValueError(f"Not calculatable whether file '{path}' exists. StdErr: '{stderr}'")
|
|
921
|
-
elif exit_code == 2:
|
|
922
|
-
return False
|
|
923
|
-
raise ValueError(f"Fatal error occurrs while checking whether file '{path}' exists. StdErr: '{stderr}'")
|
|
924
|
-
|
|
925
|
-
@staticmethod
|
|
926
|
-
@check_arguments
|
|
927
|
-
def is_folder(path: str) -> bool:
|
|
928
|
-
exit_code, _, stderr = GeneralUtilities.run_program_simple("scfolderexists", ["--path", path])
|
|
929
|
-
if exit_code == 0:
|
|
930
|
-
return True
|
|
931
|
-
elif exit_code == 1:
|
|
932
|
-
raise ValueError(f"Not calculatable whether folder '{path}' exists. StdErr: '{stderr}'")
|
|
933
|
-
elif exit_code == 2:
|
|
934
|
-
return False
|
|
935
|
-
raise ValueError(f"Fatal error occurrs while checking whether folder '{path}' exists. StdErr: '{stderr}'")
|
|
936
|
-
|
|
937
|
-
@staticmethod
|
|
938
|
-
@check_arguments
|
|
939
|
-
def is_git_repository(folder: str) -> bool:
|
|
940
|
-
combined = os.path.join(folder, ".git")
|
|
941
|
-
# TODO consider check for bare-repositories
|
|
942
|
-
return GeneralUtilities.is_file(combined) or GeneralUtilities.is_folder(combined)
|
|
943
|
-
|
|
944
|
-
@staticmethod
|
|
945
|
-
@check_arguments
|
|
946
|
-
def assert_is_git_repository(folder: str) -> str:
|
|
947
|
-
GeneralUtilities.assert_condition(GeneralUtilities.is_git_repository(folder), f"'{folder}' is not a git-repository.")
|
|
948
|
-
|
|
949
913
|
@staticmethod
|
|
950
914
|
@check_arguments
|
|
951
915
|
def assert_file_exists(file: str) -> str:
|
|
@@ -8,7 +8,7 @@ class ProgramRunnerBase:
|
|
|
8
8
|
# Return-values program_runner: Pid
|
|
9
9
|
@abstractmethod
|
|
10
10
|
@GeneralUtilities.check_arguments
|
|
11
|
-
def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> Popen:
|
|
11
|
+
def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> Popen:
|
|
12
12
|
# Verbosity:
|
|
13
13
|
# 0=Quiet (No output will be printed.)
|
|
14
14
|
# 1=Normal (If the exitcode of the executed program is not 0 then the StdErr will be printed.)
|
|
@@ -25,23 +25,28 @@ class ProgramRunnerBase:
|
|
|
25
25
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
26
26
|
@abstractmethod
|
|
27
27
|
@GeneralUtilities.check_arguments
|
|
28
|
-
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
28
|
+
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
29
29
|
raise NotImplementedError
|
|
30
30
|
|
|
31
31
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
32
32
|
@abstractmethod
|
|
33
33
|
@GeneralUtilities.check_arguments
|
|
34
|
-
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
34
|
+
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
35
35
|
raise NotImplementedError
|
|
36
36
|
|
|
37
37
|
# Return-values program_runner: Pid
|
|
38
38
|
@abstractmethod
|
|
39
39
|
@GeneralUtilities.check_arguments
|
|
40
|
-
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
|
|
40
|
+
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
41
41
|
raise NotImplementedError
|
|
42
42
|
|
|
43
43
|
# Return-values program_runner: Pid
|
|
44
44
|
@abstractmethod
|
|
45
45
|
@GeneralUtilities.check_arguments
|
|
46
|
-
def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive:bool=False) -> int:
|
|
46
|
+
def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive: bool = False) -> int:
|
|
47
|
+
raise NotImplementedError
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
@GeneralUtilities.check_arguments
|
|
51
|
+
def will_be_executed_locally(self) -> bool:
|
|
47
52
|
raise NotImplementedError
|
|
@@ -39,7 +39,7 @@ class CustomEpewArgument:
|
|
|
39
39
|
class ProgramRunnerEpew(ProgramRunnerBase):
|
|
40
40
|
|
|
41
41
|
@GeneralUtilities.check_arguments
|
|
42
|
-
def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> Popen:
|
|
42
|
+
def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> Popen:
|
|
43
43
|
if GeneralUtilities.epew_is_available():
|
|
44
44
|
custom_argument: CustomEpewArgument = custom_argument
|
|
45
45
|
args = []
|
|
@@ -67,7 +67,7 @@ class ProgramRunnerEpew(ProgramRunnerBase):
|
|
|
67
67
|
if custom_argument.addLogOverhead:
|
|
68
68
|
args.append("-g")
|
|
69
69
|
args.append("-v "+str(custom_argument.verbosity))
|
|
70
|
-
return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory,custom_argument,interactive)
|
|
70
|
+
return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory, custom_argument, interactive)
|
|
71
71
|
else:
|
|
72
72
|
raise ValueError("Epew is not available.")
|
|
73
73
|
|
|
@@ -85,21 +85,21 @@ class ProgramRunnerEpew(ProgramRunnerBase):
|
|
|
85
85
|
return result
|
|
86
86
|
|
|
87
87
|
@GeneralUtilities.check_arguments
|
|
88
|
-
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
89
|
-
process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive)
|
|
88
|
+
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
89
|
+
process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument, interactive)
|
|
90
90
|
return self.wait(process, custom_argument)
|
|
91
91
|
|
|
92
92
|
@GeneralUtilities.check_arguments
|
|
93
|
-
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
94
|
-
return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument,interactive)
|
|
93
|
+
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
94
|
+
return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument, interactive)
|
|
95
95
|
|
|
96
96
|
@GeneralUtilities.check_arguments
|
|
97
|
-
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
|
|
98
|
-
return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive).pid
|
|
97
|
+
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
98
|
+
return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument, interactive).pid
|
|
99
99
|
|
|
100
100
|
@GeneralUtilities.check_arguments
|
|
101
|
-
def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
|
|
102
|
-
return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument,interactive)
|
|
101
|
+
def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
102
|
+
return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument, interactive)
|
|
103
103
|
|
|
104
104
|
@GeneralUtilities.check_arguments
|
|
105
105
|
def __get_number_from_filecontent(self, filecontent: str) -> int:
|
|
@@ -120,3 +120,7 @@ class ProgramRunnerEpew(ProgramRunnerBase):
|
|
|
120
120
|
return content
|
|
121
121
|
else:
|
|
122
122
|
raise ValueError(f"File '{file}' does not exist")
|
|
123
|
+
|
|
124
|
+
@GeneralUtilities.check_arguments
|
|
125
|
+
def will_be_executed_locally(self) -> bool:
|
|
126
|
+
return True
|
|
@@ -51,3 +51,7 @@ class ProgramRunnerPopen(ProgramRunnerBase):
|
|
|
51
51
|
@GeneralUtilities.check_arguments
|
|
52
52
|
def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
53
53
|
return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument, interactive)
|
|
54
|
+
|
|
55
|
+
@GeneralUtilities.check_arguments
|
|
56
|
+
def will_be_executed_locally(self) -> bool:
|
|
57
|
+
return True
|
|
@@ -25,13 +25,13 @@ import yaml
|
|
|
25
25
|
import qrcode
|
|
26
26
|
import pycdlib
|
|
27
27
|
import send2trash
|
|
28
|
-
import
|
|
28
|
+
from pypdf import PdfReader, PdfWriter
|
|
29
29
|
from .GeneralUtilities import GeneralUtilities
|
|
30
30
|
from .ProgramRunnerBase import ProgramRunnerBase
|
|
31
31
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
32
32
|
from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
|
|
33
33
|
|
|
34
|
-
version = "3.5.
|
|
34
|
+
version = "3.5.54"
|
|
35
35
|
__version__ = version
|
|
36
36
|
|
|
37
37
|
|
|
@@ -147,7 +147,7 @@ class ScriptCollectionCore:
|
|
|
147
147
|
|
|
148
148
|
@GeneralUtilities.check_arguments
|
|
149
149
|
def commit_is_signed_by_key(self, repository_folder: str, revision_identifier: str, key: str) -> bool:
|
|
150
|
-
|
|
150
|
+
self.assert_is_git_repository(repository_folder)
|
|
151
151
|
result = self.run_program("git", f"verify-commit {revision_identifier}", repository_folder, throw_exception_if_exitcode_is_not_zero=False)
|
|
152
152
|
if (result[0] != 0):
|
|
153
153
|
return False
|
|
@@ -161,12 +161,12 @@ class ScriptCollectionCore:
|
|
|
161
161
|
|
|
162
162
|
@GeneralUtilities.check_arguments
|
|
163
163
|
def get_parent_commit_ids_of_commit(self, repository_folder: str, commit_id: str) -> str:
|
|
164
|
-
|
|
164
|
+
self.assert_is_git_repository(repository_folder)
|
|
165
165
|
return self.run_program("git", f'log --pretty=%P -n 1 "{commit_id}"', repository_folder, throw_exception_if_exitcode_is_not_zero=True)[1].replace("\r", "").replace("\n", "").split(" ")
|
|
166
166
|
|
|
167
167
|
@GeneralUtilities.check_arguments
|
|
168
168
|
def get_all_authors_and_committers_of_repository(self, repository_folder: str, subfolder: str = None, verbosity: int = 1) -> list[tuple[str, str]]:
|
|
169
|
-
|
|
169
|
+
self.assert_is_git_repository(repository_folder)
|
|
170
170
|
space_character = "_"
|
|
171
171
|
if subfolder is None:
|
|
172
172
|
subfolder_argument = ""
|
|
@@ -186,7 +186,7 @@ class ScriptCollectionCore:
|
|
|
186
186
|
|
|
187
187
|
@GeneralUtilities.check_arguments
|
|
188
188
|
def get_commit_ids_between_dates(self, repository_folder: str, since: datetime, until: datetime, ignore_commits_which_are_not_in_history_of_head: bool = True) -> None:
|
|
189
|
-
|
|
189
|
+
self.assert_is_git_repository(repository_folder)
|
|
190
190
|
since_as_string = self.__datetime_to_string_for_git(since)
|
|
191
191
|
until_as_string = self.__datetime_to_string_for_git(until)
|
|
192
192
|
result = filter(lambda line: not GeneralUtilities.string_is_none_or_whitespace(line), self.run_program("git", f'log --since "{since_as_string}" --until "{until_as_string}" --pretty=format:"%H" --no-patch', repository_folder, throw_exception_if_exitcode_is_not_zero=True)[1].split("\n").replace("\r", ""))
|
|
@@ -201,7 +201,7 @@ class ScriptCollectionCore:
|
|
|
201
201
|
|
|
202
202
|
@GeneralUtilities.check_arguments
|
|
203
203
|
def git_commit_is_ancestor(self, repository_folder: str, ancestor: str, descendant: str = "HEAD") -> bool:
|
|
204
|
-
|
|
204
|
+
self.assert_is_git_repository(repository_folder)
|
|
205
205
|
result = self.run_program_argsasarray("git", ["merge-base", "--is-ancestor", ancestor, descendant], repository_folder, throw_exception_if_exitcode_is_not_zero=False)
|
|
206
206
|
exit_code = result[0]
|
|
207
207
|
if exit_code == 0:
|
|
@@ -213,7 +213,7 @@ class ScriptCollectionCore:
|
|
|
213
213
|
|
|
214
214
|
@GeneralUtilities.check_arguments
|
|
215
215
|
def __git_changes_helper(self, repository_folder: str, arguments_as_array: list[str]) -> bool:
|
|
216
|
-
|
|
216
|
+
self.assert_is_git_repository(repository_folder)
|
|
217
217
|
lines = GeneralUtilities.string_to_lines(self.run_program_argsasarray("git", arguments_as_array, repository_folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)[1], False)
|
|
218
218
|
for line in lines:
|
|
219
219
|
if GeneralUtilities.string_has_content(line):
|
|
@@ -222,22 +222,22 @@ class ScriptCollectionCore:
|
|
|
222
222
|
|
|
223
223
|
@GeneralUtilities.check_arguments
|
|
224
224
|
def git_repository_has_new_untracked_files(self, repository_folder: str):
|
|
225
|
-
|
|
225
|
+
self.assert_is_git_repository(repository_folder)
|
|
226
226
|
return self.__git_changes_helper(repository_folder, ["ls-files", "--exclude-standard", "--others"])
|
|
227
227
|
|
|
228
228
|
@GeneralUtilities.check_arguments
|
|
229
229
|
def git_repository_has_unstaged_changes_of_tracked_files(self, repository_folder: str):
|
|
230
|
-
|
|
230
|
+
self.assert_is_git_repository(repository_folder)
|
|
231
231
|
return self.__git_changes_helper(repository_folder, ["--no-pager", "diff"])
|
|
232
232
|
|
|
233
233
|
@GeneralUtilities.check_arguments
|
|
234
234
|
def git_repository_has_staged_changes(self, repository_folder: str):
|
|
235
|
-
|
|
235
|
+
self.assert_is_git_repository(repository_folder)
|
|
236
236
|
return self.__git_changes_helper(repository_folder, ["--no-pager", "diff", "--cached"])
|
|
237
237
|
|
|
238
238
|
@GeneralUtilities.check_arguments
|
|
239
239
|
def git_repository_has_uncommitted_changes(self, repository_folder: str) -> bool:
|
|
240
|
-
|
|
240
|
+
self.assert_is_git_repository(repository_folder)
|
|
241
241
|
if (self.git_repository_has_unstaged_changes(repository_folder)):
|
|
242
242
|
return True
|
|
243
243
|
if (self.git_repository_has_staged_changes(repository_folder)):
|
|
@@ -246,7 +246,7 @@ class ScriptCollectionCore:
|
|
|
246
246
|
|
|
247
247
|
@GeneralUtilities.check_arguments
|
|
248
248
|
def git_repository_has_unstaged_changes(self, repository_folder: str) -> bool:
|
|
249
|
-
|
|
249
|
+
self.assert_is_git_repository(repository_folder)
|
|
250
250
|
if (self.git_repository_has_unstaged_changes_of_tracked_files(repository_folder)):
|
|
251
251
|
return True
|
|
252
252
|
if (self.git_repository_has_new_untracked_files(repository_folder)):
|
|
@@ -255,13 +255,13 @@ class ScriptCollectionCore:
|
|
|
255
255
|
|
|
256
256
|
@GeneralUtilities.check_arguments
|
|
257
257
|
def git_get_commit_id(self, repository_folder: str, commit: str = "HEAD") -> str:
|
|
258
|
-
|
|
258
|
+
self.assert_is_git_repository(repository_folder)
|
|
259
259
|
result: tuple[int, str, str, int] = self.run_program_argsasarray("git", ["rev-parse", "--verify", commit], repository_folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
|
260
260
|
return result[1].replace('\n', '')
|
|
261
261
|
|
|
262
262
|
@GeneralUtilities.check_arguments
|
|
263
263
|
def git_get_commit_date(self, repository_folder: str, commit: str = "HEAD") -> datetime:
|
|
264
|
-
|
|
264
|
+
self.assert_is_git_repository(repository_folder)
|
|
265
265
|
result: tuple[int, str, str, int] = self.run_program_argsasarray("git", ["show", "-s", "--format=%ci", commit], repository_folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
|
266
266
|
date_as_string = result[1].replace('\n', '')
|
|
267
267
|
result = datetime.strptime(date_as_string, '%Y-%m-%d %H:%M:%S %z')
|
|
@@ -464,7 +464,7 @@ class ScriptCollectionCore:
|
|
|
464
464
|
def git_fetch_or_clone_all_in_directory(self, source_directory: str, target_directory: str) -> None:
|
|
465
465
|
for subfolder in GeneralUtilities.get_direct_folders_of_folder(source_directory):
|
|
466
466
|
foldername = os.path.basename(subfolder)
|
|
467
|
-
if
|
|
467
|
+
if self.is_git_repository(subfolder):
|
|
468
468
|
source_repository = subfolder
|
|
469
469
|
target_repository = os.path.join(target_directory, foldername)
|
|
470
470
|
if os.path.isdir(target_directory):
|
|
@@ -534,20 +534,20 @@ class ScriptCollectionCore:
|
|
|
534
534
|
|
|
535
535
|
@GeneralUtilities.check_arguments
|
|
536
536
|
def get_current_git_branch_has_tag(self, repository_folder: str) -> bool:
|
|
537
|
-
|
|
537
|
+
self.assert_is_git_repository(repository_folder)
|
|
538
538
|
result = self.run_program_argsasarray("git", ["describe", "--tags", "--abbrev=0"], repository_folder, verbosity=0, throw_exception_if_exitcode_is_not_zero=False)
|
|
539
539
|
return result[0] == 0
|
|
540
540
|
|
|
541
541
|
@GeneralUtilities.check_arguments
|
|
542
542
|
def get_latest_git_tag(self, repository_folder: str) -> str:
|
|
543
|
-
|
|
543
|
+
self.assert_is_git_repository(repository_folder)
|
|
544
544
|
result = self.run_program_argsasarray("git", ["describe", "--tags", "--abbrev=0"], repository_folder, verbosity=0)
|
|
545
545
|
result = result[1].replace("\r", "").replace("\n", "")
|
|
546
546
|
return result
|
|
547
547
|
|
|
548
548
|
@GeneralUtilities.check_arguments
|
|
549
549
|
def get_staged_or_committed_git_ignored_files(self, repository_folder: str) -> list[str]:
|
|
550
|
-
|
|
550
|
+
self.assert_is_git_repository(repository_folder)
|
|
551
551
|
temp_result = self.run_program_argsasarray("git", ["ls-files", "-i", "-c", "--exclude-standard"], repository_folder, verbosity=0)
|
|
552
552
|
temp_result = temp_result[1].replace("\r", "")
|
|
553
553
|
result = [line for line in temp_result.split("\n") if len(line) > 0]
|
|
@@ -555,7 +555,7 @@ class ScriptCollectionCore:
|
|
|
555
555
|
|
|
556
556
|
@GeneralUtilities.check_arguments
|
|
557
557
|
def git_repository_has_commits(self, repository_folder: str) -> bool:
|
|
558
|
-
|
|
558
|
+
self.assert_is_git_repository(repository_folder)
|
|
559
559
|
return self.run_program_argsasarray("git", ["rev-parse", "--verify", "HEAD"], repository_folder, throw_exception_if_exitcode_is_not_zero=False)[0] == 0
|
|
560
560
|
|
|
561
561
|
@GeneralUtilities.check_arguments
|
|
@@ -609,6 +609,44 @@ class ScriptCollectionCore:
|
|
|
609
609
|
for renamed_item, original_name in renamed_items.items():
|
|
610
610
|
os.rename(renamed_item, original_name)
|
|
611
611
|
|
|
612
|
+
@GeneralUtilities.check_arguments
|
|
613
|
+
def is_file(self, path: str) -> bool:
|
|
614
|
+
if self.program_runner.will_be_executed_locally():
|
|
615
|
+
return os.path.isfile(path) # much more performant than always running an external program
|
|
616
|
+
else:
|
|
617
|
+
exit_code, _, stderr = self.run_program("scfileexists", ["--path", path], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
|
618
|
+
if exit_code == 0:
|
|
619
|
+
return True
|
|
620
|
+
elif exit_code == 1:
|
|
621
|
+
raise ValueError(f"Not calculatable whether file '{path}' exists. StdErr: '{stderr}'")
|
|
622
|
+
elif exit_code == 2:
|
|
623
|
+
return False
|
|
624
|
+
raise ValueError(f"Fatal error occurrs while checking whether file '{path}' exists. StdErr: '{stderr}'")
|
|
625
|
+
|
|
626
|
+
@GeneralUtilities.check_arguments
|
|
627
|
+
def is_folder(self, path: str) -> bool:
|
|
628
|
+
if self.program_runner.will_be_executed_locally(): # much more performant than always running an external program
|
|
629
|
+
return os.path.isdir(path)
|
|
630
|
+
else:
|
|
631
|
+
exit_code, _, stderr = self.run_program("scfolderexists", ["--path", path], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
|
632
|
+
if exit_code == 0:
|
|
633
|
+
return True
|
|
634
|
+
elif exit_code == 1:
|
|
635
|
+
raise ValueError(f"Not calculatable whether folder '{path}' exists. StdErr: '{stderr}'")
|
|
636
|
+
elif exit_code == 2:
|
|
637
|
+
return False
|
|
638
|
+
raise ValueError(f"Fatal error occurrs while checking whether folder '{path}' exists. StdErr: '{stderr}'")
|
|
639
|
+
|
|
640
|
+
@GeneralUtilities.check_arguments
|
|
641
|
+
def is_git_repository(self, folder: str) -> bool:
|
|
642
|
+
combined = f"{folder}/.git"
|
|
643
|
+
# TODO consider check for bare-repositories
|
|
644
|
+
return self.is_file(combined) or self.is_folder(combined)
|
|
645
|
+
|
|
646
|
+
@GeneralUtilities.check_arguments
|
|
647
|
+
def assert_is_git_repository(self, folder: str) -> str:
|
|
648
|
+
GeneralUtilities.assert_condition(self.is_git_repository(folder), f"'{folder}' is not a git-repository.")
|
|
649
|
+
|
|
612
650
|
@GeneralUtilities.check_arguments
|
|
613
651
|
def __sort_fmd(self, line: str):
|
|
614
652
|
splitted: list = line.split(";")
|
|
@@ -715,8 +753,8 @@ class ScriptCollectionCore:
|
|
|
715
753
|
|
|
716
754
|
@GeneralUtilities.check_arguments
|
|
717
755
|
def extract_pdf_pages(self, file: str, from_page: int, to_page: int, outputfile: str) -> None:
|
|
718
|
-
pdf_reader =
|
|
719
|
-
pdf_writer =
|
|
756
|
+
pdf_reader: PdfReader = PdfReader(file)
|
|
757
|
+
pdf_writer: PdfWriter = PdfWriter()
|
|
720
758
|
start = from_page
|
|
721
759
|
end = to_page
|
|
722
760
|
while start <= end:
|
|
@@ -728,11 +766,13 @@ class ScriptCollectionCore:
|
|
|
728
766
|
@GeneralUtilities.check_arguments
|
|
729
767
|
def merge_pdf_files(self, files: list[str], outputfile: str) -> None:
|
|
730
768
|
# TODO add wildcard-option
|
|
731
|
-
pdfFileMerger =
|
|
769
|
+
pdfFileMerger: PdfWriter = PdfWriter()
|
|
732
770
|
for file in files:
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
771
|
+
with open(file, "rb") as f:
|
|
772
|
+
pdfFileMerger.append(f)
|
|
773
|
+
with open(outputfile, "wb") as output:
|
|
774
|
+
pdfFileMerger.write(output)
|
|
775
|
+
pdfFileMerger.close()
|
|
736
776
|
|
|
737
777
|
@GeneralUtilities.check_arguments
|
|
738
778
|
def pdf_to_image(self, file: str, outputfilename_without_extension: str) -> None:
|
|
@@ -1120,7 +1160,7 @@ class ScriptCollectionCore:
|
|
|
1120
1160
|
return tor_version
|
|
1121
1161
|
|
|
1122
1162
|
def run_testcases_for_python_project(self, repository_folder: str):
|
|
1123
|
-
|
|
1163
|
+
self.assert_is_git_repository(repository_folder)
|
|
1124
1164
|
self.run_program("coverage", "run -m pytest", repository_folder)
|
|
1125
1165
|
self.run_program("coverage", "xml", repository_folder)
|
|
1126
1166
|
GeneralUtilities.ensure_directory_exists(os.path.join(repository_folder, "Other/TestCoverage"))
|
|
@@ -1534,7 +1574,7 @@ class ScriptCollectionCore:
|
|
|
1534
1574
|
|
|
1535
1575
|
@GeneralUtilities.check_arguments
|
|
1536
1576
|
def get_semver_version_from_gitversion(self, repository_folder: str) -> str:
|
|
1537
|
-
|
|
1577
|
+
self.assert_is_git_repository(repository_folder)
|
|
1538
1578
|
if (self.git_repository_has_commits(repository_folder)):
|
|
1539
1579
|
result = self.get_version_from_gitversion(repository_folder, "MajorMinorPatch")
|
|
1540
1580
|
if self.git_repository_has_uncommitted_changes(repository_folder):
|
|
@@ -39,7 +39,7 @@ class CreateReleaseConfiguration():
|
|
|
39
39
|
|
|
40
40
|
def __init__(self, projectname: str, remotename: str, build_artifacts_target_folder: str, push_artifacts_scripts_folder: str, verbosity: int, repository_folder: str, additional_arguments_file: str, repository_folder_name: str):
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
43
43
|
self.__sc = ScriptCollectionCore()
|
|
44
44
|
self.projectname = projectname
|
|
45
45
|
self.remotename = remotename
|
|
@@ -113,11 +113,10 @@ class TasksForCommonProjectStructure:
|
|
|
113
113
|
validate_developers_of_repository: bool = True
|
|
114
114
|
dotnet_runsettings_file = "runsettings.xml"
|
|
115
115
|
|
|
116
|
-
@staticmethod
|
|
117
116
|
@GeneralUtilities.check_arguments
|
|
118
|
-
def assert_is_codeunit_folder(codeunit_folder: str) -> str:
|
|
117
|
+
def assert_is_codeunit_folder(self, codeunit_folder: str) -> str:
|
|
119
118
|
repo_folder = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
|
|
120
|
-
if not
|
|
119
|
+
if not self.__sc.is_git_repository(repo_folder):
|
|
121
120
|
raise ValueError(f"'{codeunit_folder}' can not be a valid codeunit-folder because '{repo_folder}' is not a git-repository.")
|
|
122
121
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
123
122
|
codeunit_file: str = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
|
|
@@ -146,17 +145,17 @@ class TasksForCommonProjectStructure:
|
|
|
146
145
|
|
|
147
146
|
@GeneralUtilities.check_arguments
|
|
148
147
|
def get_build_folder(self, repository_folder: str, codeunit_name: str) -> str:
|
|
149
|
-
|
|
148
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
150
149
|
return os.path.join(repository_folder, codeunit_name, "Other", "Build")
|
|
151
150
|
|
|
152
151
|
@GeneralUtilities.check_arguments
|
|
153
152
|
def get_artifacts_folder(self, repository_folder: str, codeunit_name: str) -> str:
|
|
154
|
-
|
|
153
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
155
154
|
return os.path.join(repository_folder, codeunit_name, "Other", "Artifacts")
|
|
156
155
|
|
|
157
156
|
@GeneralUtilities.check_arguments
|
|
158
157
|
def get_wheel_file(self, repository_folder: str, codeunit_name: str) -> str:
|
|
159
|
-
|
|
158
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
160
159
|
return self.__sc.find_file_by_extension(os.path.join(self.get_artifacts_folder(repository_folder, codeunit_name), "BuildResult_Wheel"), "whl")
|
|
161
160
|
|
|
162
161
|
@GeneralUtilities.check_arguments
|
|
@@ -186,7 +185,7 @@ class TasksForCommonProjectStructure:
|
|
|
186
185
|
|
|
187
186
|
@GeneralUtilities.check_arguments
|
|
188
187
|
def check_testcoverage(self, testcoverage_file_in_cobertura_format: str, repository_folder: str, codeunitname: str) -> None:
|
|
189
|
-
|
|
188
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
190
189
|
GeneralUtilities.write_message_to_stdout("Check testcoverage..")
|
|
191
190
|
root: etree._ElementTree = etree.parse(testcoverage_file_in_cobertura_format)
|
|
192
191
|
if len(root.xpath('//coverage/packages/package')) != 1:
|
|
@@ -308,7 +307,7 @@ class TasksForCommonProjectStructure:
|
|
|
308
307
|
|
|
309
308
|
@GeneralUtilities.check_arguments
|
|
310
309
|
def generate_bom_for_python_project(self, verbosity: int, codeunit_folder: str, codeunitname: str, commandline_arguments: list[str]) -> None:
|
|
311
|
-
|
|
310
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
312
311
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
313
312
|
codeunitversion = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
314
313
|
bom_folder = "Other/Artifacts/BOM"
|
|
@@ -364,7 +363,7 @@ class TasksForCommonProjectStructure:
|
|
|
364
363
|
|
|
365
364
|
@GeneralUtilities.check_arguments
|
|
366
365
|
def get_version_of_codeunit_folder(self, codeunit_folder: str) -> None:
|
|
367
|
-
|
|
366
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
368
367
|
codeunit_file = os.path.join(codeunit_folder, f"{os.path.basename(codeunit_folder)}.codeunit.xml")
|
|
369
368
|
return self.get_version_of_codeunit(codeunit_file)
|
|
370
369
|
|
|
@@ -486,7 +485,7 @@ class TasksForCommonProjectStructure:
|
|
|
486
485
|
GeneralUtilities.ensure_directory_does_not_exist(obj_folder)
|
|
487
486
|
|
|
488
487
|
def standardized_task_verify_standard_format_csproj_files(self, codeunit_folder: str) -> bool:
|
|
489
|
-
|
|
488
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
490
489
|
repository_folder = os.path.dirname(codeunit_folder)
|
|
491
490
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
492
491
|
codeunit_folder = os.path.join(repository_folder, codeunit_name)
|
|
@@ -506,7 +505,7 @@ class TasksForCommonProjectStructure:
|
|
|
506
505
|
raise ValueError(test_csproj_file+message+f'"{result2[1]}".')
|
|
507
506
|
|
|
508
507
|
def __standardized_task_verify_standard_format_for_project_csproj_file(self, csproj_file: str, codeunit_folder: str, codeunit_name: str, codeunit_version: str) -> tuple[bool, str]:
|
|
509
|
-
|
|
508
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
510
509
|
codeunit_name_regex = re.escape(codeunit_name)
|
|
511
510
|
codeunit_file = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
|
|
512
511
|
codeunit_description = self.get_codeunit_description(codeunit_file)
|
|
@@ -647,7 +646,7 @@ class TasksForCommonProjectStructure:
|
|
|
647
646
|
|
|
648
647
|
@GeneralUtilities.check_arguments
|
|
649
648
|
def __standardized_tasks_build_for_dotnet_build(self, csproj_file: str, originaloutputfolder: str, files_to_sign: dict[str, str], commitid: str, verbosity: int, runtimes: list[str], target_environmenttype: str, target_environmenttype_mapping: dict[str, str], copy_license_file_to_target_folder: bool, repository_folder: str, codeunit_name: str, commandline_arguments: list[str]) -> None:
|
|
650
|
-
|
|
649
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
651
650
|
csproj_filename = os.path.basename(csproj_file)
|
|
652
651
|
GeneralUtilities.write_message_to_stdout(f"Build {csproj_filename}...")
|
|
653
652
|
dotnet_build_configuration: str = target_environmenttype_mapping[target_environmenttype]
|
|
@@ -752,7 +751,7 @@ class TasksForCommonProjectStructure:
|
|
|
752
751
|
@GeneralUtilities.check_arguments
|
|
753
752
|
def generate_sbom_for_dotnet_project(self, codeunit_folder: str, verbosity: int, commandline_arguments: list[str]) -> None:
|
|
754
753
|
GeneralUtilities.write_message_to_stdout("Generate SBOM...")
|
|
755
|
-
|
|
754
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
756
755
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
757
756
|
sc = ScriptCollectionCore()
|
|
758
757
|
bomfile_folder = "Other\\Artifacts\\BOM"
|
|
@@ -798,7 +797,7 @@ class TasksForCommonProjectStructure:
|
|
|
798
797
|
This script expectes that the testcoverage-reportfolder is '<repositorybasefolder>/<codeunitname>/Other/Artifacts/TestCoverageReport'.
|
|
799
798
|
This script expectes that a test-coverage-badges should be added to '<repositorybasefolder>/<codeunitname>/Other/Resources/Badges'."""
|
|
800
799
|
GeneralUtilities.write_message_to_stdout("Generate testcoverage report..")
|
|
801
|
-
|
|
800
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
802
801
|
codeunit_version = self.get_version_of_codeunit(os.path.join(repository_folder, codeunitname, f"{codeunitname}.codeunit.xml"))
|
|
803
802
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
804
803
|
if verbosity == 0:
|
|
@@ -868,27 +867,26 @@ class TasksForCommonProjectStructure:
|
|
|
868
867
|
|
|
869
868
|
@GeneralUtilities.check_arguments
|
|
870
869
|
def run_testcases_common_post_task(self, repository_folder: str, codeunit_name: str, verbosity: int, generate_badges: bool, targetenvironmenttype: str, commandline_arguments: list[str]) -> None:
|
|
871
|
-
|
|
870
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
872
871
|
coverage_file_folder = os.path.join(repository_folder, codeunit_name, "Other/Artifacts/TestCoverage")
|
|
873
872
|
coveragefiletarget = os.path.join(coverage_file_folder, "TestCoverage.xml")
|
|
874
873
|
self.update_path_of_source_in_testcoverage_file(repository_folder, codeunit_name)
|
|
875
874
|
self.standardized_tasks_generate_coverage_report(repository_folder, codeunit_name, verbosity, generate_badges, targetenvironmenttype, commandline_arguments)
|
|
876
875
|
self.check_testcoverage(coveragefiletarget, repository_folder, codeunit_name)
|
|
877
876
|
|
|
878
|
-
@staticmethod
|
|
879
877
|
@GeneralUtilities.check_arguments
|
|
880
|
-
def update_path_of_source_in_testcoverage_file(repository_folder: str, codeunitname: str) -> None:
|
|
881
|
-
|
|
878
|
+
def update_path_of_source_in_testcoverage_file(self, repository_folder: str, codeunitname: str) -> None:
|
|
879
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
882
880
|
GeneralUtilities.write_message_to_stdout("Update paths of source files in testcoverage files..")
|
|
883
881
|
folder = f"{repository_folder}/{codeunitname}/Other/Artifacts/TestCoverage"
|
|
884
882
|
filename = "TestCoverage.xml"
|
|
885
883
|
full_file = os.path.join(folder, filename)
|
|
886
884
|
GeneralUtilities.write_text_to_file(full_file, re.sub("<source>.+<\\/source>", f"<source><!--[repository]/-->./{codeunitname}/</source>", GeneralUtilities.read_text_from_file(full_file)))
|
|
887
|
-
|
|
885
|
+
self.__remove_not_existing_files_from_testcoverage_file(full_file, repository_folder, codeunitname)
|
|
888
886
|
|
|
889
887
|
@GeneralUtilities.check_arguments
|
|
890
888
|
def __standardized_tasks_run_testcases_for_dotnet_project_helper(self, source: str, codeunit_folder: str, match: re.Match) -> str:
|
|
891
|
-
|
|
889
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
892
890
|
filename = match.group(1)
|
|
893
891
|
file = os.path.join(source, filename)
|
|
894
892
|
# GeneralUtilities.assert_condition(os.path.isfile(file),f"File \"{file}\" does not exist.")
|
|
@@ -896,10 +894,9 @@ class TasksForCommonProjectStructure:
|
|
|
896
894
|
filename_relative = f".{file[len(codeunit_folder):]}"
|
|
897
895
|
return f'filename="{filename_relative}"'
|
|
898
896
|
|
|
899
|
-
@staticmethod
|
|
900
897
|
@GeneralUtilities.check_arguments
|
|
901
|
-
def __remove_not_existing_files_from_testcoverage_file(testcoveragefile: str, repository_folder: str, codeunit_name: str) -> None:
|
|
902
|
-
|
|
898
|
+
def __remove_not_existing_files_from_testcoverage_file(self, testcoveragefile: str, repository_folder: str, codeunit_name: str) -> None:
|
|
899
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
903
900
|
root: etree._ElementTree = etree.parse(testcoveragefile)
|
|
904
901
|
codeunit_folder = os.path.join(repository_folder, codeunit_name)
|
|
905
902
|
xpath = f"//coverage/packages/package[@name='{codeunit_name}']/classes/class"
|
|
@@ -1156,7 +1153,7 @@ class TasksForCommonProjectStructure:
|
|
|
1156
1153
|
|
|
1157
1154
|
@GeneralUtilities.check_arguments
|
|
1158
1155
|
def generate_certificate_for_development_purposes_for_product(self, repository_folder: str):
|
|
1159
|
-
|
|
1156
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1160
1157
|
product_name = os.path.basename(repository_folder)
|
|
1161
1158
|
ca_folder: str = os.path.join(repository_folder, "Other", "Resources", "CA")
|
|
1162
1159
|
self.__generate_certificate_for_development_purposes(product_name, os.path.join(repository_folder, "Other", "Resources"), ca_folder, None)
|
|
@@ -1169,7 +1166,7 @@ class TasksForCommonProjectStructure:
|
|
|
1169
1166
|
|
|
1170
1167
|
@GeneralUtilities.check_arguments
|
|
1171
1168
|
def generate_certificate_for_development_purposes_for_codeunit(self, codeunit_folder: str, domain: str = None):
|
|
1172
|
-
|
|
1169
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1173
1170
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
1174
1171
|
self.ensure_product_resource_is_imported(codeunit_folder, "CA")
|
|
1175
1172
|
ca_folder: str = os.path.join(codeunit_folder, "Other", "Resources", "CA")
|
|
@@ -1205,7 +1202,7 @@ class TasksForCommonProjectStructure:
|
|
|
1205
1202
|
@GeneralUtilities.check_arguments
|
|
1206
1203
|
def copy_product_resource_to_codeunit_resource_folder(self, codeunit_folder: str, resourcename: str) -> None:
|
|
1207
1204
|
repository_folder = GeneralUtilities.resolve_relative_path(f"..", codeunit_folder)
|
|
1208
|
-
|
|
1205
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1209
1206
|
src_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resourcename}", repository_folder)
|
|
1210
1207
|
GeneralUtilities.assert_condition(os.path.isdir(src_folder), f"Required product-resource {resourcename} does not exist. Expected folder: {src_folder}")
|
|
1211
1208
|
trg_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resourcename}", codeunit_folder)
|
|
@@ -1224,7 +1221,7 @@ class TasksForCommonProjectStructure:
|
|
|
1224
1221
|
|
|
1225
1222
|
@GeneralUtilities.check_arguments
|
|
1226
1223
|
def get_codeunits(self, repository_folder: str, ignore_disabled_codeunits: bool = True) -> list[str]:
|
|
1227
|
-
|
|
1224
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1228
1225
|
result: list[str] = []
|
|
1229
1226
|
for direct_subfolder in GeneralUtilities.get_direct_folders_of_folder(repository_folder):
|
|
1230
1227
|
subfoldername = os.path.basename(direct_subfolder)
|
|
@@ -1246,7 +1243,7 @@ class TasksForCommonProjectStructure:
|
|
|
1246
1243
|
def merge_to_main_branch(self, repository_folder: str, source_branch: str = "other/next-release", target_branch: str = "main", verbosity: int = 1, additional_arguments_file: str = None, fast_forward_source_branch: bool = False) -> None:
|
|
1247
1244
|
# This is an automatization for automatic merges. Usual this merge would be done by a pull request in a sourcecode-version-control-platform
|
|
1248
1245
|
# (like GitHub, GitLab or Azure DevOps)
|
|
1249
|
-
|
|
1246
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1250
1247
|
self.assert_no_uncommitted_changes(repository_folder)
|
|
1251
1248
|
|
|
1252
1249
|
src_branch_commit_id = self.__sc.git_get_commit_id(repository_folder, source_branch)
|
|
@@ -1273,7 +1270,7 @@ class TasksForCommonProjectStructure:
|
|
|
1273
1270
|
self.__sc.git_checkout(build_repository_folder, createRelease_configuration.build_repository_branch)
|
|
1274
1271
|
|
|
1275
1272
|
repository_folder = GeneralUtilities.resolve_relative_path(f"Submodules{os.path.sep}{createRelease_configuration.repository_folder_name}", build_repository_folder)
|
|
1276
|
-
|
|
1273
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1277
1274
|
mergeInformation = MergeToStableBranchInformationForProjectInCommonProjectFormat(repository_folder, createRelease_configuration.additional_arguments_file, createRelease_configuration.artifacts_folder)
|
|
1278
1275
|
|
|
1279
1276
|
# TODO check if repository_folder-merge-source-branch and repository_folder-merge-target-branch have different commits
|
|
@@ -1450,7 +1447,7 @@ class TasksForCommonProjectStructure:
|
|
|
1450
1447
|
raise ValueError('An empty array as argument for the "commandline_arguments"-parameter is not valid.')
|
|
1451
1448
|
commandline_arguments = commandline_arguments[1:]
|
|
1452
1449
|
repository_folder: str = str(Path(os.path.dirname(common_tasks_scripts_file)).parent.parent.absolute())
|
|
1453
|
-
|
|
1450
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1454
1451
|
codeunit_name: str = str(os.path.basename(Path(os.path.dirname(common_tasks_scripts_file)).parent.absolute()))
|
|
1455
1452
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
1456
1453
|
project_version = self.get_version_of_project(repository_folder)
|
|
@@ -1571,7 +1568,7 @@ class TasksForCommonProjectStructure:
|
|
|
1571
1568
|
|
|
1572
1569
|
@GeneralUtilities.check_arguments
|
|
1573
1570
|
def __suport_information_exists(self, repository_folder: str, version_of_product: str) -> bool:
|
|
1574
|
-
|
|
1571
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1575
1572
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
1576
1573
|
file = os.path.join(folder, "InformationAboutSupportedVersions.csv")
|
|
1577
1574
|
if not os.path.isfile(file):
|
|
@@ -1584,7 +1581,7 @@ class TasksForCommonProjectStructure:
|
|
|
1584
1581
|
|
|
1585
1582
|
@GeneralUtilities.check_arguments
|
|
1586
1583
|
def get_versions(self, repository_folder: str) -> list[(str, datetime, datetime)]:
|
|
1587
|
-
|
|
1584
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1588
1585
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
1589
1586
|
file = os.path.join(folder, "InformationAboutSupportedVersions.csv")
|
|
1590
1587
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
@@ -1597,7 +1594,7 @@ class TasksForCommonProjectStructure:
|
|
|
1597
1594
|
|
|
1598
1595
|
@GeneralUtilities.check_arguments
|
|
1599
1596
|
def get_supported_versions(self, repository_folder: str, moment: datetime) -> list[(str, datetime, datetime)]:
|
|
1600
|
-
|
|
1597
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1601
1598
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
1602
1599
|
for entry in self.get_versions(repository_folder):
|
|
1603
1600
|
if entry[1] <= moment and moment <= entry[2]:
|
|
@@ -1606,7 +1603,7 @@ class TasksForCommonProjectStructure:
|
|
|
1606
1603
|
|
|
1607
1604
|
@GeneralUtilities.check_arguments
|
|
1608
1605
|
def get_unsupported_versions(self, repository_folder: str, moment: datetime) -> list[(str, datetime, datetime)]:
|
|
1609
|
-
|
|
1606
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1610
1607
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
1611
1608
|
for entry in self.get_versions(repository_folder):
|
|
1612
1609
|
if not (entry[1] <= moment and moment <= entry[2]):
|
|
@@ -1615,7 +1612,7 @@ class TasksForCommonProjectStructure:
|
|
|
1615
1612
|
|
|
1616
1613
|
@GeneralUtilities.check_arguments
|
|
1617
1614
|
def mark_current_version_as_supported(self, repository_folder: str, version_of_product: str, supported_from: datetime, supported_until: datetime):
|
|
1618
|
-
|
|
1615
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1619
1616
|
if self.__suport_information_exists(repository_folder, version_of_product):
|
|
1620
1617
|
raise ValueError(f"Version-support for v{version_of_product} already defined.")
|
|
1621
1618
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
@@ -1642,7 +1639,7 @@ class TasksForCommonProjectStructure:
|
|
|
1642
1639
|
|
|
1643
1640
|
@GeneralUtilities.check_arguments
|
|
1644
1641
|
def generate_diff_report(self, repository_folder: str, codeunit_name: str, current_version: str) -> None:
|
|
1645
|
-
|
|
1642
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1646
1643
|
codeunit_folder = os.path.join(repository_folder, codeunit_name)
|
|
1647
1644
|
target_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/DiffReport", codeunit_folder)
|
|
1648
1645
|
GeneralUtilities.ensure_directory_does_not_exist(target_folder)
|
|
@@ -1669,12 +1666,12 @@ class TasksForCommonProjectStructure:
|
|
|
1669
1666
|
|
|
1670
1667
|
@GeneralUtilities.check_arguments
|
|
1671
1668
|
def get_version_of_project(self, repository_folder: str) -> str:
|
|
1672
|
-
|
|
1669
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1673
1670
|
return ScriptCollectionCore().get_semver_version_from_gitversion(repository_folder)
|
|
1674
1671
|
|
|
1675
1672
|
@GeneralUtilities.check_arguments
|
|
1676
1673
|
def replace_common_variables_in_nuspec_file(self, codeunit_folder: str) -> None:
|
|
1677
|
-
|
|
1674
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1678
1675
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
1679
1676
|
codeunit_version = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1680
1677
|
nuspec_file = os.path.join(codeunit_folder, "Other", "Build", f"{codeunit_name}.nuspec")
|
|
@@ -1698,7 +1695,7 @@ class TasksForCommonProjectStructure:
|
|
|
1698
1695
|
|
|
1699
1696
|
@GeneralUtilities.check_arguments
|
|
1700
1697
|
def standardized_tasks_build_bom_for_node_project(self, codeunit_folder: str, verbosity: int, commandline_arguments: list[str]) -> None:
|
|
1701
|
-
|
|
1698
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1702
1699
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
1703
1700
|
# TODO
|
|
1704
1701
|
|
|
@@ -1826,7 +1823,7 @@ class TasksForCommonProjectStructure:
|
|
|
1826
1823
|
|
|
1827
1824
|
@GeneralUtilities.check_arguments
|
|
1828
1825
|
def set_default_constants(self, codeunit_folder: str) -> None:
|
|
1829
|
-
|
|
1826
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1830
1827
|
self.set_constant_for_commitid(codeunit_folder)
|
|
1831
1828
|
self.set_constant_for_commitdate(codeunit_folder)
|
|
1832
1829
|
self.set_constant_for_codeunitname(codeunit_folder)
|
|
@@ -1836,47 +1833,47 @@ class TasksForCommonProjectStructure:
|
|
|
1836
1833
|
|
|
1837
1834
|
@GeneralUtilities.check_arguments
|
|
1838
1835
|
def set_constant_for_commitid(self, codeunit_folder: str) -> None:
|
|
1839
|
-
|
|
1836
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1840
1837
|
repository = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
|
|
1841
1838
|
commit_id = self.__sc.git_get_commit_id(repository)
|
|
1842
1839
|
self.set_constant(codeunit_folder, "CommitId", commit_id)
|
|
1843
1840
|
|
|
1844
1841
|
@GeneralUtilities.check_arguments
|
|
1845
1842
|
def set_constant_for_commitdate(self, codeunit_folder: str) -> None:
|
|
1846
|
-
|
|
1843
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1847
1844
|
repository = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
|
|
1848
1845
|
commit_date: datetime = self.__sc.git_get_commit_date(repository)
|
|
1849
1846
|
self.set_constant(codeunit_folder, "CommitDate", GeneralUtilities.datetime_to_string(commit_date))
|
|
1850
1847
|
|
|
1851
1848
|
@GeneralUtilities.check_arguments
|
|
1852
1849
|
def set_constant_for_codeunitname(self, codeunit_folder: str) -> None:
|
|
1853
|
-
|
|
1850
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1854
1851
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1855
1852
|
self.set_constant(codeunit_folder, "CodeUnitName", codeunit_name)
|
|
1856
1853
|
|
|
1857
1854
|
@GeneralUtilities.check_arguments
|
|
1858
1855
|
def set_constant_for_codeunitversion(self, codeunit_folder: str) -> None:
|
|
1859
|
-
|
|
1856
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1860
1857
|
codeunit_version: str = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1861
1858
|
self.set_constant(codeunit_folder, "CodeUnitVersion", codeunit_version)
|
|
1862
1859
|
|
|
1863
1860
|
@GeneralUtilities.check_arguments
|
|
1864
1861
|
def set_constant_for_codeunitmajorversion(self, codeunit_folder: str) -> None:
|
|
1865
|
-
|
|
1862
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1866
1863
|
codeunit_version: str = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1867
1864
|
major_version = int(codeunit_version.split(".")[0])
|
|
1868
1865
|
self.set_constant(codeunit_folder, "CodeUnitMajorVersion", str(major_version))
|
|
1869
1866
|
|
|
1870
1867
|
@GeneralUtilities.check_arguments
|
|
1871
1868
|
def set_constant_for_description(self, codeunit_folder: str) -> None:
|
|
1872
|
-
|
|
1869
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1873
1870
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1874
1871
|
codeunit_description: str = self.get_codeunit_description(f"{codeunit_folder}/{codeunit_name}.codeunit.xml")
|
|
1875
1872
|
self.set_constant(codeunit_folder, "CodeUnitDescription", codeunit_description)
|
|
1876
1873
|
|
|
1877
1874
|
@GeneralUtilities.check_arguments
|
|
1878
1875
|
def set_constant(self, codeunit_folder: str, constantname: str, constant_value: str, documentationsummary: str = None, constants_valuefile: str = None) -> None:
|
|
1879
|
-
|
|
1876
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1880
1877
|
if documentationsummary is None:
|
|
1881
1878
|
documentationsummary = ""
|
|
1882
1879
|
constants_folder = os.path.join(codeunit_folder, "Other", "Resources", "Constants")
|
|
@@ -1904,19 +1901,19 @@ class TasksForCommonProjectStructure:
|
|
|
1904
1901
|
|
|
1905
1902
|
@GeneralUtilities.check_arguments
|
|
1906
1903
|
def get_constant_value(self, source_codeunit_folder: str, constant_name: str) -> str:
|
|
1907
|
-
|
|
1904
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1908
1905
|
value_file_relative = self.__get_constant_helper(source_codeunit_folder, constant_name, "path")
|
|
1909
1906
|
value_file = GeneralUtilities.resolve_relative_path(value_file_relative, os.path.join(source_codeunit_folder, "Other", "Resources", "Constants"))
|
|
1910
1907
|
return GeneralUtilities.read_text_from_file(value_file)
|
|
1911
1908
|
|
|
1912
1909
|
@GeneralUtilities.check_arguments
|
|
1913
1910
|
def get_constant_documentation(self, source_codeunit_folder: str, constant_name: str) -> str:
|
|
1914
|
-
|
|
1911
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1915
1912
|
return self.__get_constant_helper(source_codeunit_folder, constant_name, "documentationsummary")
|
|
1916
1913
|
|
|
1917
1914
|
@GeneralUtilities.check_arguments
|
|
1918
1915
|
def __get_constant_helper(self, source_codeunit_folder: str, constant_name: str, propertyname: str) -> str:
|
|
1919
|
-
|
|
1916
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1920
1917
|
root: etree._ElementTree = etree.parse(os.path.join(source_codeunit_folder, "Other", "Resources", "Constants", f"{constant_name}.constant.xml"))
|
|
1921
1918
|
results = root.xpath(f'//cps:{propertyname}/text()', namespaces={
|
|
1922
1919
|
'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure'
|
|
@@ -1931,7 +1928,7 @@ class TasksForCommonProjectStructure:
|
|
|
1931
1928
|
|
|
1932
1929
|
@GeneralUtilities.check_arguments
|
|
1933
1930
|
def copy_development_certificate_to_default_development_directory(self, codeunit_folder: str, build_environment: str, domain: str = None, certificate_resource_name: str = "DevelopmentCertificate") -> None:
|
|
1934
|
-
|
|
1931
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1935
1932
|
if build_environment != "Productive":
|
|
1936
1933
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1937
1934
|
if domain is None:
|
|
@@ -1952,7 +1949,7 @@ class TasksForCommonProjectStructure:
|
|
|
1952
1949
|
@GeneralUtilities.check_arguments
|
|
1953
1950
|
def set_constants_for_certificate_public_information(self, codeunit_folder: str, source_constant_name: str = "DevelopmentCertificate", domain: str = None) -> None:
|
|
1954
1951
|
"""Expects a certificate-resource and generates a constant for its public information"""
|
|
1955
|
-
|
|
1952
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1956
1953
|
certificate_file = os.path.join(codeunit_folder, "Other", "Resources", source_constant_name, f"{source_constant_name}.crt")
|
|
1957
1954
|
with open(certificate_file, encoding="utf-8") as text_wrapper:
|
|
1958
1955
|
certificate = crypto.load_certificate(crypto.FILETYPE_PEM, text_wrapper.read())
|
|
@@ -1962,7 +1959,7 @@ class TasksForCommonProjectStructure:
|
|
|
1962
1959
|
@GeneralUtilities.check_arguments
|
|
1963
1960
|
def set_constants_for_certificate_private_information(self, codeunit_folder: str) -> None:
|
|
1964
1961
|
"""Expects a certificate-resource and generates a constant for its sensitive information in hex-format"""
|
|
1965
|
-
|
|
1962
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1966
1963
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
1967
1964
|
resource_name: str = "DevelopmentCertificate"
|
|
1968
1965
|
filename: str = codeunit_name+"DevelopmentCertificate"
|
|
@@ -1971,7 +1968,7 @@ class TasksForCommonProjectStructure:
|
|
|
1971
1968
|
|
|
1972
1969
|
@GeneralUtilities.check_arguments
|
|
1973
1970
|
def generate_constant_from_resource_by_filename(self, codeunit_folder: str, resource_name: str, filename: str, constant_name: str) -> None:
|
|
1974
|
-
|
|
1971
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1975
1972
|
certificate_resource_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
1976
1973
|
resource_file = os.path.join(certificate_resource_folder, filename)
|
|
1977
1974
|
resource_file_content = GeneralUtilities.read_binary_from_file(resource_file)
|
|
@@ -1980,7 +1977,7 @@ class TasksForCommonProjectStructure:
|
|
|
1980
1977
|
|
|
1981
1978
|
@GeneralUtilities.check_arguments
|
|
1982
1979
|
def generate_constant_from_resource_by_extension(self, codeunit_folder: str, resource_name: str, extension: str, constant_name: str) -> None:
|
|
1983
|
-
|
|
1980
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1984
1981
|
certificate_resource_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
1985
1982
|
resource_file = self.__sc.find_file_by_extension(certificate_resource_folder, extension)
|
|
1986
1983
|
resource_file_content = GeneralUtilities.read_binary_from_file(resource_file)
|
|
@@ -1989,7 +1986,7 @@ class TasksForCommonProjectStructure:
|
|
|
1989
1986
|
|
|
1990
1987
|
@GeneralUtilities.check_arguments
|
|
1991
1988
|
def copy_constant_from_dependent_codeunit(self, codeunit_folder: str, constant_name: str, source_codeunit_name: str) -> None:
|
|
1992
|
-
|
|
1989
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
1993
1990
|
source_codeunit_folder: str = GeneralUtilities.resolve_relative_path(f"../{source_codeunit_name}", codeunit_folder)
|
|
1994
1991
|
value = self.get_constant_value(source_codeunit_folder, constant_name)
|
|
1995
1992
|
documentation = self.get_constant_documentation(source_codeunit_folder, constant_name)
|
|
@@ -1997,7 +1994,7 @@ class TasksForCommonProjectStructure:
|
|
|
1997
1994
|
|
|
1998
1995
|
@GeneralUtilities.check_arguments
|
|
1999
1996
|
def copy_resources_from_dependent_codeunit(self, codeunit_folder: str, resource_name: str, source_codeunit_name: str) -> None:
|
|
2000
|
-
|
|
1997
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2001
1998
|
source_folder: str = GeneralUtilities.resolve_relative_path(f"../{source_codeunit_name}/Other/Resources/{resource_name}", codeunit_folder)
|
|
2002
1999
|
target_folder: str = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
2003
2000
|
GeneralUtilities.ensure_directory_does_not_exist(target_folder)
|
|
@@ -2047,7 +2044,7 @@ class TasksForCommonProjectStructure:
|
|
|
2047
2044
|
|
|
2048
2045
|
@GeneralUtilities.check_arguments
|
|
2049
2046
|
def ensure_openapigenerator_is_available(self, codeunit_folder: str) -> None:
|
|
2050
|
-
|
|
2047
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2051
2048
|
openapigenerator_folder = os.path.join(codeunit_folder, "Other", "Resources", "OpenAPIGenerator")
|
|
2052
2049
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
2053
2050
|
filename = "open-api-generator.jar"
|
|
@@ -2168,7 +2165,7 @@ class TasksForCommonProjectStructure:
|
|
|
2168
2165
|
|
|
2169
2166
|
@GeneralUtilities.check_arguments
|
|
2170
2167
|
def add_github_release(self, productname: str, projectversion: str, build_artifacts_folder: str, github_username: str, repository_folder: str, commandline_arguments: list[str]) -> None:
|
|
2171
|
-
|
|
2168
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2172
2169
|
GeneralUtilities.write_message_to_stdout(f"Create GitHub-release for {productname}.")
|
|
2173
2170
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, 1)
|
|
2174
2171
|
github_repo = f"{github_username}/{productname}"
|
|
@@ -2181,7 +2178,7 @@ class TasksForCommonProjectStructure:
|
|
|
2181
2178
|
|
|
2182
2179
|
@GeneralUtilities.check_arguments
|
|
2183
2180
|
def get_dependencies_which_are_ignored_from_updates(self, codeunit_folder: str, print_warnings_for_ignored_dependencies: bool) -> list[str]:
|
|
2184
|
-
|
|
2181
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2185
2182
|
namespaces = {'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
|
|
2186
2183
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2187
2184
|
codeunit_file = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
|
|
@@ -2255,7 +2252,7 @@ class TasksForCommonProjectStructure:
|
|
|
2255
2252
|
|
|
2256
2253
|
@GeneralUtilities.check_arguments
|
|
2257
2254
|
def generate_tasksfile_from_workspace_file(self, repository_folder: str, append_cli_args_at_end: bool = False) -> None:
|
|
2258
|
-
|
|
2255
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2259
2256
|
sc: ScriptCollectionCore = ScriptCollectionCore()
|
|
2260
2257
|
workspace_file: str = sc.find_file_by_extension(repository_folder, "code-workspace")
|
|
2261
2258
|
task_file: str = os.path.join(repository_folder, "Taskfile.yml")
|
|
@@ -2376,7 +2373,7 @@ class TasksForCommonProjectStructure:
|
|
|
2376
2373
|
|
|
2377
2374
|
@GeneralUtilities.check_arguments
|
|
2378
2375
|
def create_artifact_for_development_certificate(self, codeunit_folder: str):
|
|
2379
|
-
|
|
2376
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2380
2377
|
ce_source_folder = GeneralUtilities.resolve_relative_path("Other/Resources/DevelopmentCertificate", codeunit_folder)
|
|
2381
2378
|
ca_source_folder = GeneralUtilities.resolve_relative_path("Other/Resources/CA", codeunit_folder)
|
|
2382
2379
|
ce_target_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/DevelopmentCertificate", codeunit_folder)
|
|
@@ -2399,7 +2396,7 @@ class TasksForCommonProjectStructure:
|
|
|
2399
2396
|
|
|
2400
2397
|
@GeneralUtilities.check_arguments
|
|
2401
2398
|
def get_project_name(self, repository_folder: str) -> str:
|
|
2402
|
-
|
|
2399
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2403
2400
|
for file in GeneralUtilities.get_direct_files_of_folder(repository_folder):
|
|
2404
2401
|
if file.endswith(".code-workspace"):
|
|
2405
2402
|
return Path(file).stem
|
|
@@ -2412,14 +2409,14 @@ class TasksForCommonProjectStructure:
|
|
|
2412
2409
|
|
|
2413
2410
|
@GeneralUtilities.check_arguments
|
|
2414
2411
|
def build_codeunit(self, codeunit_folder: str, verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, export_target_directory: str = None, assume_dependent_codeunits_are_already_built: bool = False, commandlinearguments: list[str] = []) -> None:
|
|
2415
|
-
|
|
2412
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2416
2413
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2417
2414
|
repository_folder = os.path.dirname(codeunit_folder)
|
|
2418
2415
|
self.build_specific_codeunits(repository_folder, [codeunit_name], verbosity, target_environmenttype, additional_arguments_file, is_pre_merge, export_target_directory, assume_dependent_codeunits_are_already_built, commandlinearguments, False)
|
|
2419
2416
|
|
|
2420
2417
|
@GeneralUtilities.check_arguments
|
|
2421
2418
|
def build_codeunitsC(self, repository_folder: str, image: str, verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, commandlinearguments: list[str] = []) -> None:
|
|
2422
|
-
|
|
2419
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2423
2420
|
if target_environmenttype == "Development":
|
|
2424
2421
|
raise ValueError(f"build_codeunitsC is not available for target_environmenttype {target_environmenttype}.")
|
|
2425
2422
|
# TODO handle additional_arguments_file
|
|
@@ -2430,14 +2427,14 @@ class TasksForCommonProjectStructure:
|
|
|
2430
2427
|
@GeneralUtilities.check_arguments
|
|
2431
2428
|
def build_codeunits(self, repository_folder: str, verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, export_target_directory: str = None, commandline_arguments: list[str] = [], do_git_clean_when_no_changes: bool = False) -> None:
|
|
2432
2429
|
self.__check_target_environmenttype(target_environmenttype)
|
|
2433
|
-
|
|
2430
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2434
2431
|
repository_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(repository_folder)
|
|
2435
2432
|
codeunits = self.get_codeunits(repository_folder, False)
|
|
2436
2433
|
self.build_specific_codeunits(repository_folder, codeunits, verbosity, target_environmenttype, additional_arguments_file, is_pre_merge, export_target_directory, False, commandline_arguments, do_git_clean_when_no_changes)
|
|
2437
2434
|
|
|
2438
2435
|
@GeneralUtilities.check_arguments
|
|
2439
2436
|
def build_specific_codeunits(self, repository_folder: str, codeunits: list[str], verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, export_target_directory: str = None, assume_dependent_codeunits_are_already_built: bool = True, commandline_arguments: list[str] = [], do_git_clean_when_no_changes: bool = False) -> None:
|
|
2440
|
-
|
|
2437
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2441
2438
|
self.__check_target_environmenttype(target_environmenttype)
|
|
2442
2439
|
repository_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(repository_folder)
|
|
2443
2440
|
contains_uncommitted_changes = self.__sc.git_repository_has_uncommitted_changes(repository_folder)
|
|
@@ -2510,7 +2507,7 @@ class TasksForCommonProjectStructure:
|
|
|
2510
2507
|
|
|
2511
2508
|
@GeneralUtilities.check_arguments
|
|
2512
2509
|
def __do_repository_checks(self, repository_folder: str, project_version: str) -> None:
|
|
2513
|
-
|
|
2510
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2514
2511
|
self.__check_if_changelog_exists(repository_folder, project_version)
|
|
2515
2512
|
self.__check_whether_security_txt_exists(repository_folder)
|
|
2516
2513
|
self.__check_whether_workspace_file_exists(repository_folder)
|
|
@@ -2518,7 +2515,7 @@ class TasksForCommonProjectStructure:
|
|
|
2518
2515
|
|
|
2519
2516
|
@GeneralUtilities.check_arguments
|
|
2520
2517
|
def __check_if_changelog_exists(self, repository_folder: str, project_version: str) -> None:
|
|
2521
|
-
|
|
2518
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2522
2519
|
changelog_folder = os.path.join(repository_folder, "Other", "Resources", "Changelog")
|
|
2523
2520
|
changelog_file = os.path.join(changelog_folder, f"v{project_version}.md")
|
|
2524
2521
|
if not os.path.isfile(changelog_file):
|
|
@@ -2564,7 +2561,7 @@ class TasksForCommonProjectStructure:
|
|
|
2564
2561
|
|
|
2565
2562
|
@GeneralUtilities.check_arguments
|
|
2566
2563
|
def __ensure_grylibrary_is_available(self, codeunit_folder: str) -> None:
|
|
2567
|
-
|
|
2564
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2568
2565
|
grylibrary_folder = os.path.join(codeunit_folder, "Other", "Resources", "GRYLibrary")
|
|
2569
2566
|
grylibrary_dll_file = os.path.join(grylibrary_folder, "BuildResult_DotNet_win-x64", "GRYLibrary.dll")
|
|
2570
2567
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
@@ -2596,7 +2593,7 @@ class TasksForCommonProjectStructure:
|
|
|
2596
2593
|
|
|
2597
2594
|
@GeneralUtilities.check_arguments
|
|
2598
2595
|
def ensure_ffmpeg_is_available(self, codeunit_folder: str) -> None:
|
|
2599
|
-
|
|
2596
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2600
2597
|
ffmpeg_folder = os.path.join(codeunit_folder, "Other", "Resources", "FFMPEG")
|
|
2601
2598
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
2602
2599
|
exe_file = f"{ffmpeg_folder}/ffmpeg.exe"
|
|
@@ -2683,7 +2680,7 @@ class TasksForCommonProjectStructure:
|
|
|
2683
2680
|
|
|
2684
2681
|
@GeneralUtilities.check_arguments
|
|
2685
2682
|
def create_deb_package_for_artifact(self, codeunit_folder: str, maintainername: str, maintaineremail: str, description: str, verbosity: int, cmd_arguments: list[str]) -> None:
|
|
2686
|
-
|
|
2683
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2687
2684
|
verbosity = self.get_verbosity_from_commandline_arguments(cmd_arguments, verbosity)
|
|
2688
2685
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2689
2686
|
binary_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/BuildResult_DotNet_linux-x64", codeunit_folder)
|
|
@@ -2707,7 +2704,7 @@ class TasksForCommonProjectStructure:
|
|
|
2707
2704
|
|
|
2708
2705
|
@GeneralUtilities.check_arguments
|
|
2709
2706
|
def update_year_for_dotnet_codeunit(self, codeunit_folder: str) -> None:
|
|
2710
|
-
|
|
2707
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2711
2708
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2712
2709
|
csproj_file = os.path.join(codeunit_folder, codeunit_name, f"{codeunit_name}.csproj")
|
|
2713
2710
|
self.__sc.update_year_in_copyright_tags(csproj_file)
|
|
@@ -2723,7 +2720,7 @@ class TasksForCommonProjectStructure:
|
|
|
2723
2720
|
|
|
2724
2721
|
@GeneralUtilities.check_arguments
|
|
2725
2722
|
def verify_artifact_exists(self, codeunit_folder: str, artifact_name_regexes: dict[str, bool]) -> None:
|
|
2726
|
-
|
|
2723
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2727
2724
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
2728
2725
|
artifacts_folder = os.path.join(codeunit_folder, "Other/Artifacts")
|
|
2729
2726
|
existing_artifacts = [os.path.basename(x) for x in GeneralUtilities.get_direct_folders_of_folder(artifacts_folder)]
|
|
@@ -2742,7 +2739,7 @@ class TasksForCommonProjectStructure:
|
|
|
2742
2739
|
|
|
2743
2740
|
@GeneralUtilities.check_arguments
|
|
2744
2741
|
def __build_codeunit(self, codeunit_folder: str, verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, assume_dependent_codeunits_are_already_built: bool = False, commandline_arguments: list[str] = []) -> None:
|
|
2745
|
-
|
|
2742
|
+
self.__sc.assert_is_git_repository(codeunit_folder)
|
|
2746
2743
|
now = datetime.now()
|
|
2747
2744
|
codeunit_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(codeunit_folder)
|
|
2748
2745
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
@@ -2863,7 +2860,7 @@ class TasksForCommonProjectStructure:
|
|
|
2863
2860
|
@GeneralUtilities.check_arguments
|
|
2864
2861
|
def generic_update_dependencies(self, repository_folder: str, verbosity: int = 1):
|
|
2865
2862
|
# Prepare
|
|
2866
|
-
|
|
2863
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2867
2864
|
codeunits = self.get_codeunits(repository_folder)
|
|
2868
2865
|
updated_dependencies = False
|
|
2869
2866
|
update_dependencies_script_filename = "UpdateDependencies.py"
|
|
@@ -2918,12 +2915,12 @@ class TasksForCommonProjectStructure:
|
|
|
2918
2915
|
# constants
|
|
2919
2916
|
folder_of_this_file = os.path.dirname(generic_prepare_new_release_arguments.current_file)
|
|
2920
2917
|
build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
|
|
2921
|
-
|
|
2918
|
+
self.__sc.assert_is_git_repository(build_repository_folder)
|
|
2922
2919
|
|
|
2923
2920
|
repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_prepare_new_release_arguments.product_name}", folder_of_this_file)
|
|
2924
|
-
|
|
2921
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2925
2922
|
reference_folder = repository_folder+"Reference"
|
|
2926
|
-
|
|
2923
|
+
self.__sc.assert_is_git_repository(reference_folder)
|
|
2927
2924
|
verbosity: int = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(generic_prepare_new_release_arguments.commandline_arguments, 1)
|
|
2928
2925
|
|
|
2929
2926
|
merge_source_branch = "other/next-release" # TODO make this configurable
|
|
@@ -2975,7 +2972,7 @@ class TasksForCommonProjectStructure:
|
|
|
2975
2972
|
build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
|
|
2976
2973
|
repository_folder_name = generic_create_release_arguments.product_name
|
|
2977
2974
|
repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_create_release_arguments.product_name}", folder_of_this_file)
|
|
2978
|
-
|
|
2975
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2979
2976
|
|
|
2980
2977
|
merge_source_branch = "main" # TODO make this configurable
|
|
2981
2978
|
main_branch = "stable" # TODO make this configurable
|
|
@@ -3019,7 +3016,7 @@ class TasksForCommonProjectStructure:
|
|
|
3019
3016
|
|
|
3020
3017
|
@GeneralUtilities.check_arguments
|
|
3021
3018
|
def create_changelog_entry(self, repositoryfolder: str, message: str, commit: bool):
|
|
3022
|
-
|
|
3019
|
+
self.__sc.assert_is_git_repository(repositoryfolder)
|
|
3023
3020
|
current_version = self.get_version_of_project(repositoryfolder)
|
|
3024
3021
|
changelog_file = os.path.join(repositoryfolder, "Other", "Resources", "Changelog", f"v{current_version}.md")
|
|
3025
3022
|
if os.path.isdir(changelog_file):
|
|
@@ -3039,7 +3036,7 @@ class TasksForCommonProjectStructure:
|
|
|
3039
3036
|
folder_of_this_file = str(os.path.dirname(update_http_documentation_arguments.current_file))
|
|
3040
3037
|
|
|
3041
3038
|
ref_repo = GeneralUtilities.resolve_relative_path(f"../../Submodules/{update_http_documentation_arguments.reference_repository_name}", folder_of_this_file)
|
|
3042
|
-
|
|
3039
|
+
self.__sc.assert_is_git_repository(ref_repo)
|
|
3043
3040
|
self.__sc.git_checkout(ref_repo, update_http_documentation_arguments.main_branch_name)
|
|
3044
3041
|
|
|
3045
3042
|
# update reference
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ScriptCollection
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.54
|
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
|
5
5
|
Home-page: https://github.com/anionDev/ScriptCollection
|
|
6
6
|
Author: Marius Göcke
|
|
@@ -35,7 +35,7 @@ Requires-Dist: pycdlib>=1.14.0
|
|
|
35
35
|
Requires-Dist: Pygments>=2.19.1
|
|
36
36
|
Requires-Dist: pylint>=3.3.4
|
|
37
37
|
Requires-Dist: pyOpenSSL>=25.0.0
|
|
38
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: PyPDF>=5.2.0
|
|
39
39
|
Requires-Dist: pytest>=8.3.4
|
|
40
40
|
Requires-Dist: PyYAML>=6.0.2
|
|
41
41
|
Requires-Dist: qrcode>=8.0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
ScriptCollection/Executables.py,sha256=YMPkCwR4xfurYWQ2l2WcipO0hMNO2VB9ygKZsAvk5wc,24273
|
|
2
|
+
ScriptCollection/GeneralUtilities.py,sha256=OhxbpAa_0fTLCaVJo2KBXSxwNhZU1QoO1So5QJoNVkw,38602
|
|
3
|
+
ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
|
|
4
|
+
ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
|
|
5
|
+
ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
|
|
6
|
+
ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
|
|
7
|
+
ScriptCollection/RPStream.py,sha256=NRRHL3YSP3D9MuAV2jB_--0KUKCsvJGxeKnxgrRZ9kY,1545
|
|
8
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=a3Hqw8JsGiJnNGFFK2Wj5aekv31low9qm4NV72DHY3w,111102
|
|
9
|
+
ScriptCollection/TasksForCommonProjectStructure.py,sha256=BE8TLxeaFoPRsoMuXDESg_CyUsGpl20qYKYgywvqr8I,212996
|
|
10
|
+
ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
|
|
11
|
+
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
ScriptCollection-3.5.54.dist-info/METADATA,sha256=_uq1TkK8qTmFBeTMEY3EkYSS8qwyDmXtGoMpDrELHYA,7664
|
|
13
|
+
ScriptCollection-3.5.54.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
14
|
+
ScriptCollection-3.5.54.dist-info/entry_points.txt,sha256=FQ6G7VA5YX6TmEqcZD8BA-2dYRAw8Y4C5Ckl1QET95c,3145
|
|
15
|
+
ScriptCollection-3.5.54.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
16
|
+
ScriptCollection-3.5.54.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
ScriptCollection/Executables.py,sha256=YMPkCwR4xfurYWQ2l2WcipO0hMNO2VB9ygKZsAvk5wc,24273
|
|
2
|
-
ScriptCollection/GeneralUtilities.py,sha256=TBhTAMshqBbwF7WZhDv3FDfCyiNWCgiqQnXogWo0U20,40190
|
|
3
|
-
ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
|
|
4
|
-
ScriptCollection/ProgramRunnerBase.py,sha256=7QAjoqOz6XPmJH19F2k-Z1fFQB_uZnPFvn-T54IJcHQ,2324
|
|
5
|
-
ScriptCollection/ProgramRunnerEpew.py,sha256=C2Rs3YWOWWWJct7XmKphp5CF1tf0j4Fp-ljV2drLTfs,6349
|
|
6
|
-
ScriptCollection/ProgramRunnerPopen.py,sha256=UGWUK0345DmtnD1gsKa1B3tBLDzKKXUGnSbIuCSWzLU,3714
|
|
7
|
-
ScriptCollection/RPStream.py,sha256=NRRHL3YSP3D9MuAV2jB_--0KUKCsvJGxeKnxgrRZ9kY,1545
|
|
8
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=MBfnCOjjAEKrp5EUCzHKmL5n2GslR5md711hgc1Q0uo,109174
|
|
9
|
-
ScriptCollection/TasksForCommonProjectStructure.py,sha256=mmGkHrWicj6Yv_FH3eBnhj_ezwqws8noQq4L3yTQW0s,214149
|
|
10
|
-
ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
|
|
11
|
-
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
ScriptCollection-3.5.53.dist-info/METADATA,sha256=VzXKNwWcSY8BlqFac01axFr28kkhkyjHsXeXRHF2KCs,7665
|
|
13
|
-
ScriptCollection-3.5.53.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
14
|
-
ScriptCollection-3.5.53.dist-info/entry_points.txt,sha256=FQ6G7VA5YX6TmEqcZD8BA-2dYRAw8Y4C5Ckl1QET95c,3145
|
|
15
|
-
ScriptCollection-3.5.53.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
16
|
-
ScriptCollection-3.5.53.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|