ScriptCollection 3.5.53__py3-none-any.whl → 3.5.55__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 +82 -84
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.55.dist-info}/METADATA +2 -2
- ScriptCollection-3.5.55.dist-info/RECORD +16 -0
- ScriptCollection-3.5.53.dist-info/RECORD +0 -16
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.55.dist-info}/WHEEL +0 -0
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.55.dist-info}/entry_points.txt +0 -0
- {ScriptCollection-3.5.53.dist-info → ScriptCollection-3.5.55.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.55"
|
|
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):
|
|
@@ -35,11 +35,10 @@ class CreateReleaseConfiguration():
|
|
|
35
35
|
public_repository_url: str
|
|
36
36
|
additional_arguments_file: str = None
|
|
37
37
|
repository_folder_name: str = None
|
|
38
|
+
repository_folder: str = None
|
|
38
39
|
__sc: ScriptCollectionCore = None
|
|
39
40
|
|
|
40
41
|
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
|
-
|
|
42
|
-
GeneralUtilities.assert_is_git_repository(repository_folder)
|
|
43
42
|
self.__sc = ScriptCollectionCore()
|
|
44
43
|
self.projectname = projectname
|
|
45
44
|
self.remotename = remotename
|
|
@@ -52,6 +51,7 @@ class CreateReleaseConfiguration():
|
|
|
52
51
|
self.public_repository_url = self.__sc.git_get_remote_url(repository_folder, remotename)
|
|
53
52
|
self.reference_repository_remote_name = self.remotename
|
|
54
53
|
self.additional_arguments_file = additional_arguments_file
|
|
54
|
+
self.repository_folder = repository_folder
|
|
55
55
|
self.repository_folder_name = repository_folder_name
|
|
56
56
|
|
|
57
57
|
|
|
@@ -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.assert_is_codeunit_folder(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.assert_is_codeunit_folder(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.assert_is_codeunit_folder(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.assert_is_codeunit_folder(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.assert_is_codeunit_folder(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.assert_is_codeunit_folder(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)
|
|
@@ -1265,6 +1262,7 @@ class TasksForCommonProjectStructure:
|
|
|
1265
1262
|
def merge_to_stable_branch(self, create_release_file: str, createRelease_configuration: CreateReleaseConfiguration):
|
|
1266
1263
|
|
|
1267
1264
|
GeneralUtilities.write_message_to_stdout(f"Create release for project {createRelease_configuration.projectname}.")
|
|
1265
|
+
self.__sc.assert_is_git_repository(createRelease_configuration.repository_folder)
|
|
1268
1266
|
folder_of_create_release_file_file = os.path.abspath(os.path.dirname(create_release_file))
|
|
1269
1267
|
|
|
1270
1268
|
build_repository_folder = GeneralUtilities.resolve_relative_path(f"..{os.path.sep}..", folder_of_create_release_file_file)
|
|
@@ -1273,7 +1271,7 @@ class TasksForCommonProjectStructure:
|
|
|
1273
1271
|
self.__sc.git_checkout(build_repository_folder, createRelease_configuration.build_repository_branch)
|
|
1274
1272
|
|
|
1275
1273
|
repository_folder = GeneralUtilities.resolve_relative_path(f"Submodules{os.path.sep}{createRelease_configuration.repository_folder_name}", build_repository_folder)
|
|
1276
|
-
|
|
1274
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1277
1275
|
mergeInformation = MergeToStableBranchInformationForProjectInCommonProjectFormat(repository_folder, createRelease_configuration.additional_arguments_file, createRelease_configuration.artifacts_folder)
|
|
1278
1276
|
|
|
1279
1277
|
# TODO check if repository_folder-merge-source-branch and repository_folder-merge-target-branch have different commits
|
|
@@ -1450,7 +1448,7 @@ class TasksForCommonProjectStructure:
|
|
|
1450
1448
|
raise ValueError('An empty array as argument for the "commandline_arguments"-parameter is not valid.')
|
|
1451
1449
|
commandline_arguments = commandline_arguments[1:]
|
|
1452
1450
|
repository_folder: str = str(Path(os.path.dirname(common_tasks_scripts_file)).parent.parent.absolute())
|
|
1453
|
-
|
|
1451
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1454
1452
|
codeunit_name: str = str(os.path.basename(Path(os.path.dirname(common_tasks_scripts_file)).parent.absolute()))
|
|
1455
1453
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
1456
1454
|
project_version = self.get_version_of_project(repository_folder)
|
|
@@ -1571,7 +1569,7 @@ class TasksForCommonProjectStructure:
|
|
|
1571
1569
|
|
|
1572
1570
|
@GeneralUtilities.check_arguments
|
|
1573
1571
|
def __suport_information_exists(self, repository_folder: str, version_of_product: str) -> bool:
|
|
1574
|
-
|
|
1572
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1575
1573
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
1576
1574
|
file = os.path.join(folder, "InformationAboutSupportedVersions.csv")
|
|
1577
1575
|
if not os.path.isfile(file):
|
|
@@ -1584,7 +1582,7 @@ class TasksForCommonProjectStructure:
|
|
|
1584
1582
|
|
|
1585
1583
|
@GeneralUtilities.check_arguments
|
|
1586
1584
|
def get_versions(self, repository_folder: str) -> list[(str, datetime, datetime)]:
|
|
1587
|
-
|
|
1585
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1588
1586
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
1589
1587
|
file = os.path.join(folder, "InformationAboutSupportedVersions.csv")
|
|
1590
1588
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
@@ -1597,7 +1595,7 @@ class TasksForCommonProjectStructure:
|
|
|
1597
1595
|
|
|
1598
1596
|
@GeneralUtilities.check_arguments
|
|
1599
1597
|
def get_supported_versions(self, repository_folder: str, moment: datetime) -> list[(str, datetime, datetime)]:
|
|
1600
|
-
|
|
1598
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1601
1599
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
1602
1600
|
for entry in self.get_versions(repository_folder):
|
|
1603
1601
|
if entry[1] <= moment and moment <= entry[2]:
|
|
@@ -1606,7 +1604,7 @@ class TasksForCommonProjectStructure:
|
|
|
1606
1604
|
|
|
1607
1605
|
@GeneralUtilities.check_arguments
|
|
1608
1606
|
def get_unsupported_versions(self, repository_folder: str, moment: datetime) -> list[(str, datetime, datetime)]:
|
|
1609
|
-
|
|
1607
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1610
1608
|
result: list[str] = list[(str, datetime, datetime)]()
|
|
1611
1609
|
for entry in self.get_versions(repository_folder):
|
|
1612
1610
|
if not (entry[1] <= moment and moment <= entry[2]):
|
|
@@ -1615,7 +1613,7 @@ class TasksForCommonProjectStructure:
|
|
|
1615
1613
|
|
|
1616
1614
|
@GeneralUtilities.check_arguments
|
|
1617
1615
|
def mark_current_version_as_supported(self, repository_folder: str, version_of_product: str, supported_from: datetime, supported_until: datetime):
|
|
1618
|
-
|
|
1616
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1619
1617
|
if self.__suport_information_exists(repository_folder, version_of_product):
|
|
1620
1618
|
raise ValueError(f"Version-support for v{version_of_product} already defined.")
|
|
1621
1619
|
folder = os.path.join(repository_folder, "Other", "Resources", "Support")
|
|
@@ -1642,7 +1640,7 @@ class TasksForCommonProjectStructure:
|
|
|
1642
1640
|
|
|
1643
1641
|
@GeneralUtilities.check_arguments
|
|
1644
1642
|
def generate_diff_report(self, repository_folder: str, codeunit_name: str, current_version: str) -> None:
|
|
1645
|
-
|
|
1643
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1646
1644
|
codeunit_folder = os.path.join(repository_folder, codeunit_name)
|
|
1647
1645
|
target_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/DiffReport", codeunit_folder)
|
|
1648
1646
|
GeneralUtilities.ensure_directory_does_not_exist(target_folder)
|
|
@@ -1669,12 +1667,12 @@ class TasksForCommonProjectStructure:
|
|
|
1669
1667
|
|
|
1670
1668
|
@GeneralUtilities.check_arguments
|
|
1671
1669
|
def get_version_of_project(self, repository_folder: str) -> str:
|
|
1672
|
-
|
|
1670
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
1673
1671
|
return ScriptCollectionCore().get_semver_version_from_gitversion(repository_folder)
|
|
1674
1672
|
|
|
1675
1673
|
@GeneralUtilities.check_arguments
|
|
1676
1674
|
def replace_common_variables_in_nuspec_file(self, codeunit_folder: str) -> None:
|
|
1677
|
-
|
|
1675
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1678
1676
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
1679
1677
|
codeunit_version = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1680
1678
|
nuspec_file = os.path.join(codeunit_folder, "Other", "Build", f"{codeunit_name}.nuspec")
|
|
@@ -1698,7 +1696,7 @@ class TasksForCommonProjectStructure:
|
|
|
1698
1696
|
|
|
1699
1697
|
@GeneralUtilities.check_arguments
|
|
1700
1698
|
def standardized_tasks_build_bom_for_node_project(self, codeunit_folder: str, verbosity: int, commandline_arguments: list[str]) -> None:
|
|
1701
|
-
|
|
1699
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1702
1700
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, verbosity)
|
|
1703
1701
|
# TODO
|
|
1704
1702
|
|
|
@@ -1826,7 +1824,7 @@ class TasksForCommonProjectStructure:
|
|
|
1826
1824
|
|
|
1827
1825
|
@GeneralUtilities.check_arguments
|
|
1828
1826
|
def set_default_constants(self, codeunit_folder: str) -> None:
|
|
1829
|
-
|
|
1827
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1830
1828
|
self.set_constant_for_commitid(codeunit_folder)
|
|
1831
1829
|
self.set_constant_for_commitdate(codeunit_folder)
|
|
1832
1830
|
self.set_constant_for_codeunitname(codeunit_folder)
|
|
@@ -1836,47 +1834,47 @@ class TasksForCommonProjectStructure:
|
|
|
1836
1834
|
|
|
1837
1835
|
@GeneralUtilities.check_arguments
|
|
1838
1836
|
def set_constant_for_commitid(self, codeunit_folder: str) -> None:
|
|
1839
|
-
|
|
1837
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1840
1838
|
repository = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
|
|
1841
1839
|
commit_id = self.__sc.git_get_commit_id(repository)
|
|
1842
1840
|
self.set_constant(codeunit_folder, "CommitId", commit_id)
|
|
1843
1841
|
|
|
1844
1842
|
@GeneralUtilities.check_arguments
|
|
1845
1843
|
def set_constant_for_commitdate(self, codeunit_folder: str) -> None:
|
|
1846
|
-
|
|
1844
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1847
1845
|
repository = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
|
|
1848
1846
|
commit_date: datetime = self.__sc.git_get_commit_date(repository)
|
|
1849
1847
|
self.set_constant(codeunit_folder, "CommitDate", GeneralUtilities.datetime_to_string(commit_date))
|
|
1850
1848
|
|
|
1851
1849
|
@GeneralUtilities.check_arguments
|
|
1852
1850
|
def set_constant_for_codeunitname(self, codeunit_folder: str) -> None:
|
|
1853
|
-
|
|
1851
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1854
1852
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1855
1853
|
self.set_constant(codeunit_folder, "CodeUnitName", codeunit_name)
|
|
1856
1854
|
|
|
1857
1855
|
@GeneralUtilities.check_arguments
|
|
1858
1856
|
def set_constant_for_codeunitversion(self, codeunit_folder: str) -> None:
|
|
1859
|
-
|
|
1857
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1860
1858
|
codeunit_version: str = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1861
1859
|
self.set_constant(codeunit_folder, "CodeUnitVersion", codeunit_version)
|
|
1862
1860
|
|
|
1863
1861
|
@GeneralUtilities.check_arguments
|
|
1864
1862
|
def set_constant_for_codeunitmajorversion(self, codeunit_folder: str) -> None:
|
|
1865
|
-
|
|
1863
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1866
1864
|
codeunit_version: str = self.get_version_of_codeunit_folder(codeunit_folder)
|
|
1867
1865
|
major_version = int(codeunit_version.split(".")[0])
|
|
1868
1866
|
self.set_constant(codeunit_folder, "CodeUnitMajorVersion", str(major_version))
|
|
1869
1867
|
|
|
1870
1868
|
@GeneralUtilities.check_arguments
|
|
1871
1869
|
def set_constant_for_description(self, codeunit_folder: str) -> None:
|
|
1872
|
-
|
|
1870
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1873
1871
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1874
1872
|
codeunit_description: str = self.get_codeunit_description(f"{codeunit_folder}/{codeunit_name}.codeunit.xml")
|
|
1875
1873
|
self.set_constant(codeunit_folder, "CodeUnitDescription", codeunit_description)
|
|
1876
1874
|
|
|
1877
1875
|
@GeneralUtilities.check_arguments
|
|
1878
1876
|
def set_constant(self, codeunit_folder: str, constantname: str, constant_value: str, documentationsummary: str = None, constants_valuefile: str = None) -> None:
|
|
1879
|
-
|
|
1877
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1880
1878
|
if documentationsummary is None:
|
|
1881
1879
|
documentationsummary = ""
|
|
1882
1880
|
constants_folder = os.path.join(codeunit_folder, "Other", "Resources", "Constants")
|
|
@@ -1904,19 +1902,19 @@ class TasksForCommonProjectStructure:
|
|
|
1904
1902
|
|
|
1905
1903
|
@GeneralUtilities.check_arguments
|
|
1906
1904
|
def get_constant_value(self, source_codeunit_folder: str, constant_name: str) -> str:
|
|
1907
|
-
|
|
1905
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1908
1906
|
value_file_relative = self.__get_constant_helper(source_codeunit_folder, constant_name, "path")
|
|
1909
1907
|
value_file = GeneralUtilities.resolve_relative_path(value_file_relative, os.path.join(source_codeunit_folder, "Other", "Resources", "Constants"))
|
|
1910
1908
|
return GeneralUtilities.read_text_from_file(value_file)
|
|
1911
1909
|
|
|
1912
1910
|
@GeneralUtilities.check_arguments
|
|
1913
1911
|
def get_constant_documentation(self, source_codeunit_folder: str, constant_name: str) -> str:
|
|
1914
|
-
|
|
1912
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1915
1913
|
return self.__get_constant_helper(source_codeunit_folder, constant_name, "documentationsummary")
|
|
1916
1914
|
|
|
1917
1915
|
@GeneralUtilities.check_arguments
|
|
1918
1916
|
def __get_constant_helper(self, source_codeunit_folder: str, constant_name: str, propertyname: str) -> str:
|
|
1919
|
-
|
|
1917
|
+
self.__sc.assert_is_git_repository(source_codeunit_folder)
|
|
1920
1918
|
root: etree._ElementTree = etree.parse(os.path.join(source_codeunit_folder, "Other", "Resources", "Constants", f"{constant_name}.constant.xml"))
|
|
1921
1919
|
results = root.xpath(f'//cps:{propertyname}/text()', namespaces={
|
|
1922
1920
|
'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure'
|
|
@@ -1931,7 +1929,7 @@ class TasksForCommonProjectStructure:
|
|
|
1931
1929
|
|
|
1932
1930
|
@GeneralUtilities.check_arguments
|
|
1933
1931
|
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
|
-
|
|
1932
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1935
1933
|
if build_environment != "Productive":
|
|
1936
1934
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
1937
1935
|
if domain is None:
|
|
@@ -1952,7 +1950,7 @@ class TasksForCommonProjectStructure:
|
|
|
1952
1950
|
@GeneralUtilities.check_arguments
|
|
1953
1951
|
def set_constants_for_certificate_public_information(self, codeunit_folder: str, source_constant_name: str = "DevelopmentCertificate", domain: str = None) -> None:
|
|
1954
1952
|
"""Expects a certificate-resource and generates a constant for its public information"""
|
|
1955
|
-
|
|
1953
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1956
1954
|
certificate_file = os.path.join(codeunit_folder, "Other", "Resources", source_constant_name, f"{source_constant_name}.crt")
|
|
1957
1955
|
with open(certificate_file, encoding="utf-8") as text_wrapper:
|
|
1958
1956
|
certificate = crypto.load_certificate(crypto.FILETYPE_PEM, text_wrapper.read())
|
|
@@ -1962,7 +1960,7 @@ class TasksForCommonProjectStructure:
|
|
|
1962
1960
|
@GeneralUtilities.check_arguments
|
|
1963
1961
|
def set_constants_for_certificate_private_information(self, codeunit_folder: str) -> None:
|
|
1964
1962
|
"""Expects a certificate-resource and generates a constant for its sensitive information in hex-format"""
|
|
1965
|
-
|
|
1963
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1966
1964
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
1967
1965
|
resource_name: str = "DevelopmentCertificate"
|
|
1968
1966
|
filename: str = codeunit_name+"DevelopmentCertificate"
|
|
@@ -1971,7 +1969,7 @@ class TasksForCommonProjectStructure:
|
|
|
1971
1969
|
|
|
1972
1970
|
@GeneralUtilities.check_arguments
|
|
1973
1971
|
def generate_constant_from_resource_by_filename(self, codeunit_folder: str, resource_name: str, filename: str, constant_name: str) -> None:
|
|
1974
|
-
|
|
1972
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1975
1973
|
certificate_resource_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
1976
1974
|
resource_file = os.path.join(certificate_resource_folder, filename)
|
|
1977
1975
|
resource_file_content = GeneralUtilities.read_binary_from_file(resource_file)
|
|
@@ -1980,7 +1978,7 @@ class TasksForCommonProjectStructure:
|
|
|
1980
1978
|
|
|
1981
1979
|
@GeneralUtilities.check_arguments
|
|
1982
1980
|
def generate_constant_from_resource_by_extension(self, codeunit_folder: str, resource_name: str, extension: str, constant_name: str) -> None:
|
|
1983
|
-
|
|
1981
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1984
1982
|
certificate_resource_folder = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
1985
1983
|
resource_file = self.__sc.find_file_by_extension(certificate_resource_folder, extension)
|
|
1986
1984
|
resource_file_content = GeneralUtilities.read_binary_from_file(resource_file)
|
|
@@ -1989,7 +1987,7 @@ class TasksForCommonProjectStructure:
|
|
|
1989
1987
|
|
|
1990
1988
|
@GeneralUtilities.check_arguments
|
|
1991
1989
|
def copy_constant_from_dependent_codeunit(self, codeunit_folder: str, constant_name: str, source_codeunit_name: str) -> None:
|
|
1992
|
-
|
|
1990
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
1993
1991
|
source_codeunit_folder: str = GeneralUtilities.resolve_relative_path(f"../{source_codeunit_name}", codeunit_folder)
|
|
1994
1992
|
value = self.get_constant_value(source_codeunit_folder, constant_name)
|
|
1995
1993
|
documentation = self.get_constant_documentation(source_codeunit_folder, constant_name)
|
|
@@ -1997,7 +1995,7 @@ class TasksForCommonProjectStructure:
|
|
|
1997
1995
|
|
|
1998
1996
|
@GeneralUtilities.check_arguments
|
|
1999
1997
|
def copy_resources_from_dependent_codeunit(self, codeunit_folder: str, resource_name: str, source_codeunit_name: str) -> None:
|
|
2000
|
-
|
|
1998
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2001
1999
|
source_folder: str = GeneralUtilities.resolve_relative_path(f"../{source_codeunit_name}/Other/Resources/{resource_name}", codeunit_folder)
|
|
2002
2000
|
target_folder: str = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
|
|
2003
2001
|
GeneralUtilities.ensure_directory_does_not_exist(target_folder)
|
|
@@ -2047,7 +2045,7 @@ class TasksForCommonProjectStructure:
|
|
|
2047
2045
|
|
|
2048
2046
|
@GeneralUtilities.check_arguments
|
|
2049
2047
|
def ensure_openapigenerator_is_available(self, codeunit_folder: str) -> None:
|
|
2050
|
-
|
|
2048
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2051
2049
|
openapigenerator_folder = os.path.join(codeunit_folder, "Other", "Resources", "OpenAPIGenerator")
|
|
2052
2050
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
2053
2051
|
filename = "open-api-generator.jar"
|
|
@@ -2168,7 +2166,7 @@ class TasksForCommonProjectStructure:
|
|
|
2168
2166
|
|
|
2169
2167
|
@GeneralUtilities.check_arguments
|
|
2170
2168
|
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
|
-
|
|
2169
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2172
2170
|
GeneralUtilities.write_message_to_stdout(f"Create GitHub-release for {productname}.")
|
|
2173
2171
|
verbosity = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(commandline_arguments, 1)
|
|
2174
2172
|
github_repo = f"{github_username}/{productname}"
|
|
@@ -2181,7 +2179,7 @@ class TasksForCommonProjectStructure:
|
|
|
2181
2179
|
|
|
2182
2180
|
@GeneralUtilities.check_arguments
|
|
2183
2181
|
def get_dependencies_which_are_ignored_from_updates(self, codeunit_folder: str, print_warnings_for_ignored_dependencies: bool) -> list[str]:
|
|
2184
|
-
|
|
2182
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2185
2183
|
namespaces = {'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure', 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
|
|
2186
2184
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2187
2185
|
codeunit_file = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
|
|
@@ -2255,7 +2253,7 @@ class TasksForCommonProjectStructure:
|
|
|
2255
2253
|
|
|
2256
2254
|
@GeneralUtilities.check_arguments
|
|
2257
2255
|
def generate_tasksfile_from_workspace_file(self, repository_folder: str, append_cli_args_at_end: bool = False) -> None:
|
|
2258
|
-
|
|
2256
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2259
2257
|
sc: ScriptCollectionCore = ScriptCollectionCore()
|
|
2260
2258
|
workspace_file: str = sc.find_file_by_extension(repository_folder, "code-workspace")
|
|
2261
2259
|
task_file: str = os.path.join(repository_folder, "Taskfile.yml")
|
|
@@ -2376,7 +2374,7 @@ class TasksForCommonProjectStructure:
|
|
|
2376
2374
|
|
|
2377
2375
|
@GeneralUtilities.check_arguments
|
|
2378
2376
|
def create_artifact_for_development_certificate(self, codeunit_folder: str):
|
|
2379
|
-
|
|
2377
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2380
2378
|
ce_source_folder = GeneralUtilities.resolve_relative_path("Other/Resources/DevelopmentCertificate", codeunit_folder)
|
|
2381
2379
|
ca_source_folder = GeneralUtilities.resolve_relative_path("Other/Resources/CA", codeunit_folder)
|
|
2382
2380
|
ce_target_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/DevelopmentCertificate", codeunit_folder)
|
|
@@ -2399,7 +2397,7 @@ class TasksForCommonProjectStructure:
|
|
|
2399
2397
|
|
|
2400
2398
|
@GeneralUtilities.check_arguments
|
|
2401
2399
|
def get_project_name(self, repository_folder: str) -> str:
|
|
2402
|
-
|
|
2400
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2403
2401
|
for file in GeneralUtilities.get_direct_files_of_folder(repository_folder):
|
|
2404
2402
|
if file.endswith(".code-workspace"):
|
|
2405
2403
|
return Path(file).stem
|
|
@@ -2412,14 +2410,14 @@ class TasksForCommonProjectStructure:
|
|
|
2412
2410
|
|
|
2413
2411
|
@GeneralUtilities.check_arguments
|
|
2414
2412
|
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
|
-
|
|
2413
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2416
2414
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2417
2415
|
repository_folder = os.path.dirname(codeunit_folder)
|
|
2418
2416
|
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
2417
|
|
|
2420
2418
|
@GeneralUtilities.check_arguments
|
|
2421
2419
|
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
|
-
|
|
2420
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2423
2421
|
if target_environmenttype == "Development":
|
|
2424
2422
|
raise ValueError(f"build_codeunitsC is not available for target_environmenttype {target_environmenttype}.")
|
|
2425
2423
|
# TODO handle additional_arguments_file
|
|
@@ -2430,14 +2428,14 @@ class TasksForCommonProjectStructure:
|
|
|
2430
2428
|
@GeneralUtilities.check_arguments
|
|
2431
2429
|
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
2430
|
self.__check_target_environmenttype(target_environmenttype)
|
|
2433
|
-
|
|
2431
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2434
2432
|
repository_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(repository_folder)
|
|
2435
2433
|
codeunits = self.get_codeunits(repository_folder, False)
|
|
2436
2434
|
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
2435
|
|
|
2438
2436
|
@GeneralUtilities.check_arguments
|
|
2439
2437
|
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
|
-
|
|
2438
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2441
2439
|
self.__check_target_environmenttype(target_environmenttype)
|
|
2442
2440
|
repository_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(repository_folder)
|
|
2443
2441
|
contains_uncommitted_changes = self.__sc.git_repository_has_uncommitted_changes(repository_folder)
|
|
@@ -2510,7 +2508,7 @@ class TasksForCommonProjectStructure:
|
|
|
2510
2508
|
|
|
2511
2509
|
@GeneralUtilities.check_arguments
|
|
2512
2510
|
def __do_repository_checks(self, repository_folder: str, project_version: str) -> None:
|
|
2513
|
-
|
|
2511
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2514
2512
|
self.__check_if_changelog_exists(repository_folder, project_version)
|
|
2515
2513
|
self.__check_whether_security_txt_exists(repository_folder)
|
|
2516
2514
|
self.__check_whether_workspace_file_exists(repository_folder)
|
|
@@ -2518,7 +2516,7 @@ class TasksForCommonProjectStructure:
|
|
|
2518
2516
|
|
|
2519
2517
|
@GeneralUtilities.check_arguments
|
|
2520
2518
|
def __check_if_changelog_exists(self, repository_folder: str, project_version: str) -> None:
|
|
2521
|
-
|
|
2519
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2522
2520
|
changelog_folder = os.path.join(repository_folder, "Other", "Resources", "Changelog")
|
|
2523
2521
|
changelog_file = os.path.join(changelog_folder, f"v{project_version}.md")
|
|
2524
2522
|
if not os.path.isfile(changelog_file):
|
|
@@ -2564,7 +2562,7 @@ class TasksForCommonProjectStructure:
|
|
|
2564
2562
|
|
|
2565
2563
|
@GeneralUtilities.check_arguments
|
|
2566
2564
|
def __ensure_grylibrary_is_available(self, codeunit_folder: str) -> None:
|
|
2567
|
-
|
|
2565
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2568
2566
|
grylibrary_folder = os.path.join(codeunit_folder, "Other", "Resources", "GRYLibrary")
|
|
2569
2567
|
grylibrary_dll_file = os.path.join(grylibrary_folder, "BuildResult_DotNet_win-x64", "GRYLibrary.dll")
|
|
2570
2568
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
@@ -2596,7 +2594,7 @@ class TasksForCommonProjectStructure:
|
|
|
2596
2594
|
|
|
2597
2595
|
@GeneralUtilities.check_arguments
|
|
2598
2596
|
def ensure_ffmpeg_is_available(self, codeunit_folder: str) -> None:
|
|
2599
|
-
|
|
2597
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2600
2598
|
ffmpeg_folder = os.path.join(codeunit_folder, "Other", "Resources", "FFMPEG")
|
|
2601
2599
|
internet_connection_is_available = GeneralUtilities.internet_connection_is_available()
|
|
2602
2600
|
exe_file = f"{ffmpeg_folder}/ffmpeg.exe"
|
|
@@ -2683,7 +2681,7 @@ class TasksForCommonProjectStructure:
|
|
|
2683
2681
|
|
|
2684
2682
|
@GeneralUtilities.check_arguments
|
|
2685
2683
|
def create_deb_package_for_artifact(self, codeunit_folder: str, maintainername: str, maintaineremail: str, description: str, verbosity: int, cmd_arguments: list[str]) -> None:
|
|
2686
|
-
|
|
2684
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2687
2685
|
verbosity = self.get_verbosity_from_commandline_arguments(cmd_arguments, verbosity)
|
|
2688
2686
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2689
2687
|
binary_folder = GeneralUtilities.resolve_relative_path("Other/Artifacts/BuildResult_DotNet_linux-x64", codeunit_folder)
|
|
@@ -2707,7 +2705,7 @@ class TasksForCommonProjectStructure:
|
|
|
2707
2705
|
|
|
2708
2706
|
@GeneralUtilities.check_arguments
|
|
2709
2707
|
def update_year_for_dotnet_codeunit(self, codeunit_folder: str) -> None:
|
|
2710
|
-
|
|
2708
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2711
2709
|
codeunit_name = os.path.basename(codeunit_folder)
|
|
2712
2710
|
csproj_file = os.path.join(codeunit_folder, codeunit_name, f"{codeunit_name}.csproj")
|
|
2713
2711
|
self.__sc.update_year_in_copyright_tags(csproj_file)
|
|
@@ -2723,7 +2721,7 @@ class TasksForCommonProjectStructure:
|
|
|
2723
2721
|
|
|
2724
2722
|
@GeneralUtilities.check_arguments
|
|
2725
2723
|
def verify_artifact_exists(self, codeunit_folder: str, artifact_name_regexes: dict[str, bool]) -> None:
|
|
2726
|
-
|
|
2724
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2727
2725
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
2728
2726
|
artifacts_folder = os.path.join(codeunit_folder, "Other/Artifacts")
|
|
2729
2727
|
existing_artifacts = [os.path.basename(x) for x in GeneralUtilities.get_direct_folders_of_folder(artifacts_folder)]
|
|
@@ -2742,7 +2740,7 @@ class TasksForCommonProjectStructure:
|
|
|
2742
2740
|
|
|
2743
2741
|
@GeneralUtilities.check_arguments
|
|
2744
2742
|
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
|
-
|
|
2743
|
+
self.assert_is_codeunit_folder(codeunit_folder)
|
|
2746
2744
|
now = datetime.now()
|
|
2747
2745
|
codeunit_folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(codeunit_folder)
|
|
2748
2746
|
codeunit_name: str = os.path.basename(codeunit_folder)
|
|
@@ -2863,7 +2861,7 @@ class TasksForCommonProjectStructure:
|
|
|
2863
2861
|
@GeneralUtilities.check_arguments
|
|
2864
2862
|
def generic_update_dependencies(self, repository_folder: str, verbosity: int = 1):
|
|
2865
2863
|
# Prepare
|
|
2866
|
-
|
|
2864
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2867
2865
|
codeunits = self.get_codeunits(repository_folder)
|
|
2868
2866
|
updated_dependencies = False
|
|
2869
2867
|
update_dependencies_script_filename = "UpdateDependencies.py"
|
|
@@ -2918,12 +2916,12 @@ class TasksForCommonProjectStructure:
|
|
|
2918
2916
|
# constants
|
|
2919
2917
|
folder_of_this_file = os.path.dirname(generic_prepare_new_release_arguments.current_file)
|
|
2920
2918
|
build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
|
|
2921
|
-
|
|
2919
|
+
self.__sc.assert_is_git_repository(build_repository_folder)
|
|
2922
2920
|
|
|
2923
2921
|
repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_prepare_new_release_arguments.product_name}", folder_of_this_file)
|
|
2924
|
-
|
|
2922
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2925
2923
|
reference_folder = repository_folder+"Reference"
|
|
2926
|
-
|
|
2924
|
+
self.__sc.assert_is_git_repository(reference_folder)
|
|
2927
2925
|
verbosity: int = TasksForCommonProjectStructure.get_verbosity_from_commandline_arguments(generic_prepare_new_release_arguments.commandline_arguments, 1)
|
|
2928
2926
|
|
|
2929
2927
|
merge_source_branch = "other/next-release" # TODO make this configurable
|
|
@@ -2975,7 +2973,7 @@ class TasksForCommonProjectStructure:
|
|
|
2975
2973
|
build_repository_folder = GeneralUtilities.resolve_relative_path("../..", folder_of_this_file)
|
|
2976
2974
|
repository_folder_name = generic_create_release_arguments.product_name
|
|
2977
2975
|
repository_folder = GeneralUtilities.resolve_relative_path(f"../../Submodules/{generic_create_release_arguments.product_name}", folder_of_this_file)
|
|
2978
|
-
|
|
2976
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
|
2979
2977
|
|
|
2980
2978
|
merge_source_branch = "main" # TODO make this configurable
|
|
2981
2979
|
main_branch = "stable" # TODO make this configurable
|
|
@@ -3019,7 +3017,7 @@ class TasksForCommonProjectStructure:
|
|
|
3019
3017
|
|
|
3020
3018
|
@GeneralUtilities.check_arguments
|
|
3021
3019
|
def create_changelog_entry(self, repositoryfolder: str, message: str, commit: bool):
|
|
3022
|
-
|
|
3020
|
+
self.__sc.assert_is_git_repository(repositoryfolder)
|
|
3023
3021
|
current_version = self.get_version_of_project(repositoryfolder)
|
|
3024
3022
|
changelog_file = os.path.join(repositoryfolder, "Other", "Resources", "Changelog", f"v{current_version}.md")
|
|
3025
3023
|
if os.path.isdir(changelog_file):
|
|
@@ -3039,7 +3037,7 @@ class TasksForCommonProjectStructure:
|
|
|
3039
3037
|
folder_of_this_file = str(os.path.dirname(update_http_documentation_arguments.current_file))
|
|
3040
3038
|
|
|
3041
3039
|
ref_repo = GeneralUtilities.resolve_relative_path(f"../../Submodules/{update_http_documentation_arguments.reference_repository_name}", folder_of_this_file)
|
|
3042
|
-
|
|
3040
|
+
self.__sc.assert_is_git_repository(ref_repo)
|
|
3043
3041
|
self.__sc.git_checkout(ref_repo, update_http_documentation_arguments.main_branch_name)
|
|
3044
3042
|
|
|
3045
3043
|
# update reference
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ScriptCollection
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.55
|
|
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=e2-Csid-AKc39trT6jVR1fU9DrNHuq8iE7dRRw2UTP0,111102
|
|
9
|
+
ScriptCollection/TasksForCommonProjectStructure.py,sha256=SaX_1ulRQLmO7FzRsIMPXKq48Z7hFYuRJVLi3aJHRj8,212976
|
|
10
|
+
ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
|
|
11
|
+
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
ScriptCollection-3.5.55.dist-info/METADATA,sha256=msJci7lCJUbXECRyPwgcN4xLXQPuVQ36g_Sc-pSERo4,7664
|
|
13
|
+
ScriptCollection-3.5.55.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
14
|
+
ScriptCollection-3.5.55.dist-info/entry_points.txt,sha256=FQ6G7VA5YX6TmEqcZD8BA-2dYRAw8Y4C5Ckl1QET95c,3145
|
|
15
|
+
ScriptCollection-3.5.55.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
16
|
+
ScriptCollection-3.5.55.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
|