ScriptCollection 4.3.61__py3-none-any.whl → 4.3.62__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.
@@ -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.61"
42
+ version = "4.3.62"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -3080,7 +3080,18 @@ TXDX
3080
3080
  trim_texts(child)
3081
3081
  trim_texts(element)
3082
3082
  ET.indent(element)
3083
- content = ET.tostring(element, xml_declaration=add_xml_declaration, encoding="unicode")
3083
+ default_namespace = None
3084
+ if element.tag.startswith("{"):
3085
+ #keep the namespace of the root-element as default-namespace. without this the whole document would be rewritten with a
3086
+ #generated prefix (for example "<ns0:package xmlns:ns0=...>" instead of "<package xmlns=...>"), which is semantically
3087
+ #equivalent but unusual and therefore an unnecessary risk for tools which process the formatted file.
3088
+ default_namespace = element.tag[1:element.tag.index("}")]
3089
+ try:
3090
+ content = ET.tostring(element, xml_declaration=add_xml_declaration, encoding="unicode", default_namespace=default_namespace)
3091
+ except ValueError:
3092
+ #documents which contain elements without a namespace besides the namespace of the root-element can not be serialized
3093
+ #with a default-namespace at all. in that case the generated prefixes are the only possible representation.
3094
+ content = ET.tostring(element, xml_declaration=add_xml_declaration, encoding="unicode")
3084
3095
  GeneralUtilities.write_text_to_file(file, content.rstrip("\n") + "\n", encoding)
3085
3096
  self.normalize_line_endings(file)
3086
3097
 
@@ -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
- Already existing sources are updated instead of being replaced, and sources which are not declared are not touched at all: the
32
- registration is stored in the NuGet-configuration of the current user, which - when the build runs directly on the host - is
33
- the configuration the user also uses for their own work and which must not be destroyed by a build."""
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
- #a source which is already registered is updated instead of being added a second time. It is searched by its url and not only
41
- #by its name, because the same feed can already be registered under a different name (which is the usual case on a machine on
42
- #which the user configured the feed manually) and a second registration of the same url would let every restore query it twice.
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 self.__nuget_sources_are_equal(registered_url, package_source.url) or registered_name.lower() == package_source.name:
46
- existing_name = registered_name
47
- break
48
- if existing_name is None:
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", existing_name, "--source", package_source.url]
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 existing_name is None else f"Update the already registered NuGet-source \"{existing_name}\" ({package_source.url})...", LogLevel.Debug)
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+\[(?:Enabled|Disabled)\]\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)
@@ -322,8 +335,10 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
322
335
  def linting(self) -> None:
323
336
  codeunit_name = self.get_codeunit_name()
324
337
  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
338
  self._protected_sc.normalize_line_endings_of_files_in_folder(codeunit_folder, ["cs"])
339
+ nuspec_file = os.path.join(codeunit_folder, "Other", "Build", f"{codeunit_name}.nuspec")
340
+ if os.path.isfile(nuspec_file):
341
+ self._protected_sc.format_xml_file(nuspec_file)
327
342
  self._protected_sc.format_xml_file(os.path.join(codeunit_folder, codeunit_name, codeunit_name + ".csproj"), add_xml_declaration=False)
328
343
  self._protected_sc.format_xml_file(os.path.join(codeunit_folder, codeunit_name + "Tests", codeunit_name + "Tests.csproj"), add_xml_declaration=False)
329
344
  self.standardized_task_verify_standard_format_csproj_files()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.61
3
+ Version: 4.3.62
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=-2uuSZc2m-gPq5FkDC13aHIaaRAVtmsijobxd0onhaQ,249975
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=2tircN632E5TOfz8VuxJdmZzShedu3gIVNf7-xaJK_c,250936
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=oIJooRrhr3ZlBZ2uEviJ7xEB0AItW4I7e19Oa28MRA0,47184
56
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=_Eiv7LR2JTE_NztTJLfQW69IVHcQRD9kEuclD_bwTgM,48694
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.61.dist-info/METADATA,sha256=Ju2RPrINNdI_xckarsrawCQVjV7GC2SNPA8FbkARC0o,7648
71
- scriptcollection-4.3.61.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
72
- scriptcollection-4.3.61.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
73
- scriptcollection-4.3.61.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
74
- scriptcollection-4.3.61.dist-info/RECORD,,
70
+ scriptcollection-4.3.62.dist-info/METADATA,sha256=fmWD13cbeLiy0J_qNoAOGwwPmXMec4f_CVjdNtpUJVE,7648
71
+ scriptcollection-4.3.62.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
72
+ scriptcollection-4.3.62.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
73
+ scriptcollection-4.3.62.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
74
+ scriptcollection-4.3.62.dist-info/RECORD,,