ScriptCollection 4.3.61__py3-none-any.whl → 4.3.63__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/ScriptCollectionCore.py +30 -4
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +42 -22
- {scriptcollection-4.3.61.dist-info → scriptcollection-4.3.63.dist-info}/METADATA +1 -1
- {scriptcollection-4.3.61.dist-info → scriptcollection-4.3.63.dist-info}/RECORD +7 -7
- {scriptcollection-4.3.61.dist-info → scriptcollection-4.3.63.dist-info}/WHEEL +0 -0
- {scriptcollection-4.3.61.dist-info → scriptcollection-4.3.63.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.3.61.dist-info → scriptcollection-4.3.63.dist-info}/top_level.txt +0 -0
|
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
|
|
|
39
39
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
40
40
|
from .SCLog import SCLog, LogLevel
|
|
41
41
|
|
|
42
|
-
version = "4.3.
|
|
42
|
+
version = "4.3.63"
|
|
43
43
|
__version__ = version
|
|
44
44
|
|
|
45
45
|
class VSCodeWorkspaceShellTask:
|
|
@@ -458,7 +458,9 @@ class ScriptCollectionCore:
|
|
|
458
458
|
versiononlyregex = f"^{versionregex}$"
|
|
459
459
|
pattern = re.compile(versiononlyregex)
|
|
460
460
|
if pattern.match(new_version):
|
|
461
|
-
|
|
461
|
+
#the tag can be prefixed (for example "<ns0:version>") because the nuspec-namespace can be declared with a prefix instead of being declared as default-namespace.
|
|
462
|
+
version_tag_regex = f"(<(?:[\\w.-]+:)?version>){versionregex}(<\\/(?:[\\w.-]+:)?version>)"
|
|
463
|
+
GeneralUtilities.write_text_to_file(nuspec_file, re.sub(version_tag_regex, lambda match: match.group(1)+new_version+match.group(2), GeneralUtilities.read_text_from_file(nuspec_file)))
|
|
462
464
|
else:
|
|
463
465
|
raise ValueError(f"Version '{new_version}' does not match version-regex '{versiononlyregex}'")
|
|
464
466
|
|
|
@@ -2835,7 +2837,8 @@ chmod {permission} {link_file}
|
|
|
2835
2837
|
lines = GeneralUtilities.read_lines_from_file(file)
|
|
2836
2838
|
lines_result = []
|
|
2837
2839
|
for line in lines:
|
|
2838
|
-
|
|
2840
|
+
#the tag can be prefixed (for example "<ns0:copyright>") because in xml-files like nuspec-files the namespace can be declared with a prefix instead of being declared as default-namespace.
|
|
2841
|
+
if match := re.search("(.*<(?:[\\w.-]+:)?[Cc]opyright>.*)\\d\\d\\d\\d(.*<\\/(?:[\\w.-]+:)?[Cc]opyright>.*)", line):
|
|
2839
2842
|
part1 = match.group(1)
|
|
2840
2843
|
part2 = match.group(2)
|
|
2841
2844
|
adapted = part1+current_year+part2
|
|
@@ -3080,10 +3083,33 @@ TXDX
|
|
|
3080
3083
|
trim_texts(child)
|
|
3081
3084
|
trim_texts(element)
|
|
3082
3085
|
ET.indent(element)
|
|
3083
|
-
content =
|
|
3086
|
+
content = self.__serialize_xml_element(element, add_xml_declaration)
|
|
3084
3087
|
GeneralUtilities.write_text_to_file(file, content.rstrip("\n") + "\n", encoding)
|
|
3085
3088
|
self.normalize_line_endings(file)
|
|
3086
3089
|
|
|
3090
|
+
@GeneralUtilities.check_arguments
|
|
3091
|
+
def __serialize_xml_element(self, element: ET.Element, add_xml_declaration: bool) -> str:
|
|
3092
|
+
if not element.tag.startswith("{"):
|
|
3093
|
+
return ET.tostring(element, xml_declaration=add_xml_declaration, encoding="unicode")
|
|
3094
|
+
#keep the namespace of the root-element as default-namespace. without this the whole document would be rewritten with a
|
|
3095
|
+
#generated prefix (for example "<ns0:package xmlns:ns0=...>" instead of "<package xmlns=...>"), which is semantically
|
|
3096
|
+
#equivalent but unusual and therefore an unnecessary risk for tools which process the formatted file.
|
|
3097
|
+
#the "default_namespace"-argument of "tostring" can not be used for this because it rejects documents which contain
|
|
3098
|
+
#attributes without a namespace (which is the usual case, for example in nuspec-files), so the namespace is registered
|
|
3099
|
+
#as default-namespace instead. that registration is global, therefore the previous state gets restored afterwards.
|
|
3100
|
+
namespace = element.tag[1:element.tag.index("}")]
|
|
3101
|
+
namespace_map: dict = getattr(ET, "_namespace_map", None)
|
|
3102
|
+
previous_prefix = namespace_map.get(namespace) if namespace_map is not None else None
|
|
3103
|
+
ET.register_namespace(GeneralUtilities.empty_string, namespace)
|
|
3104
|
+
try:
|
|
3105
|
+
return ET.tostring(element, xml_declaration=add_xml_declaration, encoding="unicode")
|
|
3106
|
+
finally:
|
|
3107
|
+
if namespace_map is not None:
|
|
3108
|
+
if previous_prefix is None:
|
|
3109
|
+
namespace_map.pop(namespace, None)
|
|
3110
|
+
else:
|
|
3111
|
+
namespace_map[namespace] = previous_prefix
|
|
3112
|
+
|
|
3087
3113
|
@GeneralUtilities.check_arguments
|
|
3088
3114
|
def format_html_file(self, file: str, add_html_declaration: bool = False) -> None:
|
|
3089
3115
|
encoding = "utf-8"
|
|
@@ -15,6 +15,8 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
15
15
|
|
|
16
16
|
is_library:bool = None
|
|
17
17
|
csproj_file:bool = None
|
|
18
|
+
#the output of the dotnet-cli is localized. The language is set explicitly for the commands whose output gets parsed, because otherwise the parsing would only work on machines which are configured to use english.
|
|
19
|
+
__dotnet_cli_environment_variables:dict = {"DOTNET_CLI_UI_LANGUAGE": "en-US"}
|
|
18
20
|
|
|
19
21
|
def __init__(self,current_file:str,verbosity:LogLevel,targetenvironmenttype:str,use_cache:bool,is_pre_merge:bool):
|
|
20
22
|
super().__init__(current_file, verbosity,targetenvironmenttype,use_cache,is_pre_merge)
|
|
@@ -28,28 +30,33 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
28
30
|
def __ensure_declared_package_sources_are_available(self) -> None:
|
|
29
31
|
"""Ensures that every NuGet-source which is declared for this machine (see TFCPS_Tools_General.get_declared_package_sources) is
|
|
30
32
|
registered with its current credentials, so a codeunit can also use dependencies which are not available on nuget.org.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
the
|
|
33
|
+
A source which is already registered under the declared name is removed and registered again, so an outdated registration (for
|
|
34
|
+
example one which points to another url) can not let the registration fail. Sources which are not declared are not touched at
|
|
35
|
+
all: the registration is stored in the NuGet-configuration of the current user, which - when the build runs directly on the
|
|
36
|
+
host - is the configuration the user also uses for their own work and which must not be destroyed by a build."""
|
|
34
37
|
package_sources: list[PackageSource] = self.tfcps_Tools_General.get_declared_package_sources("CSharp")
|
|
35
38
|
if len(package_sources) == 0:
|
|
36
39
|
return
|
|
37
40
|
codeunit_folder: str = self.get_codeunit_folder()
|
|
38
|
-
registered_sources: dict[str, str] = self.__get_registered_nuget_sources(codeunit_folder)
|
|
39
41
|
for package_source in package_sources:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
existing_name: str = None
|
|
42
|
+
registered_sources: dict[str, str] = self.__get_registered_nuget_sources(codeunit_folder)
|
|
43
|
+
name_of_source_with_same_name: str = None
|
|
44
|
+
name_of_source_with_same_url: str = None
|
|
44
45
|
for registered_name, registered_url in registered_sources.items():
|
|
45
|
-
if
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if registered_name.lower() == package_source.name.lower():
|
|
47
|
+
name_of_source_with_same_name = registered_name
|
|
48
|
+
elif self.__nuget_sources_are_equal(registered_url, package_source.url):
|
|
49
|
+
#the same feed can already be registered under another name (which is the usual case on a machine on which the user
|
|
50
|
+
#configured the feed manually). Such a source is updated instead of being added a second time, because a second
|
|
51
|
+
#registration of the same url would let every restore query the feed twice.
|
|
52
|
+
name_of_source_with_same_url = registered_name
|
|
53
|
+
if name_of_source_with_same_name is not None:
|
|
54
|
+
self.__remove_nuget_source(codeunit_folder, name_of_source_with_same_name)
|
|
55
|
+
if name_of_source_with_same_url is None:
|
|
49
56
|
arguments = ["nuget", "add", "source", package_source.url, "--name", package_source.name]
|
|
50
57
|
else:
|
|
51
58
|
#the credentials are set again even when the source already exists, because a token can have been rotated since it was registered.
|
|
52
|
-
arguments = ["nuget", "update", "source",
|
|
59
|
+
arguments = ["nuget", "update", "source", name_of_source_with_same_url, "--source", package_source.url]
|
|
53
60
|
if package_source.has_credentials():
|
|
54
61
|
arguments = arguments+["--username", package_source.username, "--password", package_source.password]
|
|
55
62
|
if not GeneralUtilities.current_system_is_windows():
|
|
@@ -58,8 +65,14 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
58
65
|
arguments_for_log = list(arguments)
|
|
59
66
|
if package_source.has_credentials():
|
|
60
67
|
arguments_for_log[arguments_for_log.index(package_source.password)] = "***"#the password must not be written to the build-log
|
|
61
|
-
self._protected_sc.log.log(f"Add NuGet-source \"{package_source.name}\" ({package_source.url})..." if
|
|
62
|
-
self._protected_sc.run_program_argsasarray("dotnet", arguments, codeunit_folder, arguments_for_log=arguments_for_log, print_live_output=False)
|
|
68
|
+
self._protected_sc.log.log(f"Add NuGet-source \"{package_source.name}\" ({package_source.url})..." if name_of_source_with_same_url is None else f"Update the already registered NuGet-source \"{name_of_source_with_same_url}\" ({package_source.url})...", LogLevel.Debug)
|
|
69
|
+
self._protected_sc.run_program_argsasarray("dotnet", arguments, codeunit_folder, arguments_for_log=arguments_for_log, print_live_output=False, env_vars=self.__dotnet_cli_environment_variables)
|
|
70
|
+
|
|
71
|
+
@GeneralUtilities.check_arguments
|
|
72
|
+
def __remove_nuget_source(self, folder: str, name: str) -> None:
|
|
73
|
+
"""Removes the registration of the NuGet-source with the given name, so it can be registered again with its currently declared url and credentials."""
|
|
74
|
+
self._protected_sc.log.log(f"Remove the outdated registration of the NuGet-source \"{name}\"...", LogLevel.Debug)
|
|
75
|
+
self._protected_sc.run_program_argsasarray("dotnet", ["nuget", "remove", "source", name], folder, print_live_output=False, env_vars=self.__dotnet_cli_environment_variables)
|
|
63
76
|
|
|
64
77
|
@GeneralUtilities.check_arguments
|
|
65
78
|
def __get_registered_nuget_sources(self, folder: str) -> dict[str, str]:
|
|
@@ -67,8 +80,8 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
67
80
|
read from the output of "dotnet nuget list source", which prints the name (with its state) and the url of a source in two
|
|
68
81
|
consecutive lines."""
|
|
69
82
|
result: dict[str, str] = {}
|
|
70
|
-
list_result = self._protected_sc.run_program_argsasarray("dotnet", ["nuget", "list", "source"], folder, throw_exception_if_exitcode_is_not_zero=False, print_live_output=False)
|
|
71
|
-
name_pattern = re.compile(r"^\s*\d+\.\s+(.+?)\s+\[
|
|
83
|
+
list_result = self._protected_sc.run_program_argsasarray("dotnet", ["nuget", "list", "source"], folder, throw_exception_if_exitcode_is_not_zero=False, print_live_output=False, env_vars=self.__dotnet_cli_environment_variables)
|
|
84
|
+
name_pattern = re.compile(r"^\s*\d+\.\s+(.+?)\s+\[[^\[\]]+\]\s*$")
|
|
72
85
|
current_name: str = None
|
|
73
86
|
for line in list_result[1].splitlines():
|
|
74
87
|
match = name_pattern.match(line)
|
|
@@ -244,13 +257,18 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
244
257
|
repository_folder: str =self.get_repository_folder()
|
|
245
258
|
build_folder = os.path.join(repository_folder, codeunitname, "Other", "Build")
|
|
246
259
|
outputfolder = GeneralUtilities.resolve_relative_path("./Other/Artifacts/BuildResult_NuGet",self.get_codeunit_folder())
|
|
247
|
-
|
|
248
|
-
|
|
260
|
+
nuspec_file = os.path.join(build_folder, f"{codeunitname}.nuspec")
|
|
261
|
+
root: etree._ElementTree = etree.parse(nuspec_file)
|
|
262
|
+
# the elements are matched by their local name because the nuspec-namespace can be declared as default-namespace
|
|
263
|
+
# (<package xmlns="...">) as well as with a prefix (<ns0:package xmlns:ns0="...">) and both variants are valid.
|
|
264
|
+
versions = root.xpath("//*[local-name() = 'package']/*[local-name() = 'metadata']/*[local-name() = 'version']/text()")
|
|
265
|
+
if len(versions) == 0:
|
|
266
|
+
raise ValueError(f"Can not determine the version because there is no version-element in \"{nuspec_file}\".")
|
|
267
|
+
current_version = versions[0]
|
|
249
268
|
nupkg_filename = f"{codeunitname}.{current_version}.nupkg"
|
|
250
269
|
nupkg_file = f"{build_folder}/{nupkg_filename}"
|
|
251
270
|
GeneralUtilities.ensure_file_does_not_exist(nupkg_file)
|
|
252
271
|
commit_id = self._protected_sc.git_get_commit_id(repository_folder)
|
|
253
|
-
nuspec_file = os.path.join(build_folder, f"{codeunitname}.nuspec")
|
|
254
272
|
# Pack the hand-written nuspec using "dotnet pack" (the classic "nuget pack" is not available in the dotnet-only build-container).
|
|
255
273
|
# With NuspecFile the package-content is taken entirely from the nuspec's <files>-list, so no rebuild happens here (the library was already built before).
|
|
256
274
|
self._protected_sc.run_program_argsasarray("dotnet", [
|
|
@@ -322,8 +340,10 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
322
340
|
def linting(self) -> None:
|
|
323
341
|
codeunit_name = self.get_codeunit_name()
|
|
324
342
|
codeunit_folder = self.get_codeunit_folder()
|
|
325
|
-
# Normalize the line-endings of all non-git-ignored *.cs-files in the codeunit- and the test-project to LF.
|
|
326
343
|
self._protected_sc.normalize_line_endings_of_files_in_folder(codeunit_folder, ["cs"])
|
|
344
|
+
nuspec_file = os.path.join(codeunit_folder, "Other", "Build", f"{codeunit_name}.nuspec")
|
|
345
|
+
if os.path.isfile(nuspec_file):
|
|
346
|
+
self._protected_sc.format_xml_file(nuspec_file)
|
|
327
347
|
self._protected_sc.format_xml_file(os.path.join(codeunit_folder, codeunit_name, codeunit_name + ".csproj"), add_xml_declaration=False)
|
|
328
348
|
self._protected_sc.format_xml_file(os.path.join(codeunit_folder, codeunit_name + "Tests", codeunit_name + "Tests.csproj"), add_xml_declaration=False)
|
|
329
349
|
self.standardized_task_verify_standard_format_csproj_files()
|
|
@@ -605,7 +625,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
605
625
|
test_working_directory = os.path.join(temp_folder, "WorkingDirectory")
|
|
606
626
|
GeneralUtilities.ensure_directory_exists(test_working_directory)
|
|
607
627
|
try:
|
|
608
|
-
program_output=self._protected_sc.run_program_argsasarray("dotnet", args, test_working_directory, print_live_output=self.get_verbosity()==LogLevel.Debug, timeoutInSeconds=60*
|
|
628
|
+
program_output=self._protected_sc.run_program_argsasarray("dotnet", args, test_working_directory, print_live_output=self.get_verbosity()==LogLevel.Debug, timeoutInSeconds=60*45, env_vars={"MSBUILDDISABLENODEREUSE": "1"})
|
|
609
629
|
test_output:str=program_output[1]
|
|
610
630
|
output_lines=program_output[1].split("\n")
|
|
611
631
|
output_lines=[line for line in output_lines if GeneralUtilities.string_has_content(line)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.63
|
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
|
5
5
|
Author-email: Marius Göcke <marius.goecke@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
|
|
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
|
|
|
9
9
|
ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
|
|
10
10
|
ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
|
|
11
11
|
ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
|
|
12
|
-
ScriptCollection/ScriptCollectionCore.py,sha256
|
|
12
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=sdpTesYpkC35Y57jDFVRb5hwgP7qdztVIgegwRuqjak,252141
|
|
13
13
|
ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
|
|
14
14
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
|
|
@@ -53,7 +53,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
53
53
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
|
|
54
54
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
|
|
55
55
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
|
|
56
|
-
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=
|
|
56
|
+
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=ypanFntsqBd5wfHQMCRkZAh-tLH9xmLnykKm7gdnPMw,49097
|
|
57
57
|
ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=CwDBogG7Lg3IyywpCGta9gcaqWpgjENNXaupS19ZwTM,8751
|
|
59
59
|
ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -67,8 +67,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
|
|
|
67
67
|
ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
68
|
ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
|
|
69
69
|
ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
-
scriptcollection-4.3.
|
|
71
|
-
scriptcollection-4.3.
|
|
72
|
-
scriptcollection-4.3.
|
|
73
|
-
scriptcollection-4.3.
|
|
74
|
-
scriptcollection-4.3.
|
|
70
|
+
scriptcollection-4.3.63.dist-info/METADATA,sha256=YAUlnQVtR2cF7t1yzjkSAkHdzNaI9P-FOf1M7QwB4Ts,7648
|
|
71
|
+
scriptcollection-4.3.63.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
72
|
+
scriptcollection-4.3.63.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
|
|
73
|
+
scriptcollection-4.3.63.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
74
|
+
scriptcollection-4.3.63.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|