ScriptCollection 4.4.31__py3-none-any.whl → 4.4.33__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.
@@ -40,7 +40,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
40
40
  from .ProgramRunnerPopen import ProgramRunnerPopen
41
41
  from .SCLog import SCLog, LogLevel
42
42
 
43
- version = "4.4.31"
43
+ version = "4.4.33"
44
44
  __version__ = version
45
45
 
46
46
  class VSCodeWorkspaceShellTask:
@@ -325,7 +325,14 @@ class ScriptCollectionCore:
325
325
  get_environment_variables_file_in_container), if the variable is defined there.
326
326
  - the environment of the current process otherwise. This is how a build-pipeline provides a value from its own secret-store.
327
327
  The configuration-file has precedence, so a resolved value does not depend on what happens to be set in the environment of the
328
- caller. If a value can not be determined in either way the resolution fails with a message which names both possibilities.
328
+ caller. That precedence only applies as long as the source which the file names is actually available here: a 'file'-entry which
329
+ points outside the configuration-folder (a secret-file of the host) and a 'hostenvvariable'-entry both name something which exists
330
+ on the machine the command was started on but not inside a build-container, which only gets the configuration-file itself. In that
331
+ case the value is taken from the environment instead, because that is where the host put the value it resolved before it started
332
+ the container (see TFCPS_CodeUnit_BuildCodeUnits.__run_scriptcollection_executable_in_container, which forwards every required
333
+ variable by name). Without that fallback, making the configuration-file visible inside a container would break exactly those
334
+ entries which only the host can resolve.
335
+ If a value can not be determined in either way the resolution fails with a message which names both possibilities.
329
336
  This function centralizes the resolution so every caller (the required environment-variables of a product as well as the
330
337
  OCI-registry-credentials, see get_docker_registry_credentials_from_environment_variables) obtains identical values instead of
331
338
  re-implementing the resolution-logic. 'required_by' names the thing which needs the values and is used in the error-message when a
@@ -334,10 +341,16 @@ class ScriptCollectionCore:
334
341
  configuration_file: str = self.__get_global_environment_variables_configuration_file()
335
342
  entries: dict[str, tuple[str, str]] = self.__read_environment_variables_configuration_file(configuration_file)
336
343
  for environment_variable_name in environment_variable_names:
344
+ value_from_environment: str = os.environ.get(environment_variable_name)
337
345
  if environment_variable_name in entries:
338
- result[environment_variable_name] = self.__resolve_environment_variable_value(environment_variable_name, entries[environment_variable_name], configuration_file)
346
+ try:
347
+ result[environment_variable_name] = self.__resolve_environment_variable_value(environment_variable_name, entries[environment_variable_name], configuration_file)
348
+ continue
349
+ except Exception as exception:
350
+ GeneralUtilities.assert_condition(GeneralUtilities.string_has_content(value_from_environment), f"The value of the environment-variable '{environment_variable_name}' which is required by {required_by} can not be determined: '{configuration_file}' defines where it comes from, but that source is not available here ({GeneralUtilities.exception_to_str(exception)}), and the variable is not set in the environment either.")
351
+ self.log.log(f"The value of the environment-variable '{environment_variable_name}' is taken from the environment because the source which '{configuration_file}' defines for it is not available here.", LogLevel.Debug)
352
+ result[environment_variable_name] = value_from_environment
339
353
  else:
340
- value_from_environment: str = os.environ.get(environment_variable_name)
341
354
  GeneralUtilities.assert_condition(GeneralUtilities.string_has_content(value_from_environment), f"The value of the environment-variable '{environment_variable_name}' which is required by {required_by} is unknown: it is not defined in '{configuration_file}' and it is not set in the environment. Add a line '{environment_variable_name};<kind>;<value>' to that file (allowed kinds are: {', '.join(ScriptCollectionCore.__allowed_environment_variable_kinds)}) or provide the value as an environment-variable, which is how a build-pipeline usually provides it.")
342
355
  result[environment_variable_name] = value_from_environment
343
356
  return result
@@ -4698,13 +4711,35 @@ OCR-content:
4698
4711
 
4699
4712
  @GeneralUtilities.check_arguments
4700
4713
  def translate_xlf_files_in_folder(self, folder: str, base_language: str, libre_translate_api_server: str):
4701
- """Translates all .xlf files directly in the given folder (non-recursive)."""
4714
+ """Translates all .xlf files directly in the given folder (non-recursive).
4715
+
4716
+ Only the languages the translation-service really offers are translated. Which languages a project has is
4717
+ its own decision and a LibreTranslate-instance knows a limited set of them, so a project which has one
4718
+ language the instance does not know is the normal case and not a defect - its texts stay untranslated
4719
+ (which is what the fallback to the base-language exists for) and every other language is translated.
4720
+ Without this, the first unknown language would end the whole run with an error and the languages behind it
4721
+ would stay untranslated as well."""
4702
4722
  pattern = re.compile(r'^.+\.[a-z]{2,3}\.xlf$')
4703
- for filename in os.listdir(folder):
4723
+ supported_languages = self.get_supported_translation_languages(libre_translate_api_server)
4724
+ skipped_languages: list[str] = []
4725
+ for filename in sorted(os.listdir(folder)):
4704
4726
  if not pattern.match(filename):
4705
4727
  continue
4728
+ language = filename.split(".")[-2]
4729
+ if language not in supported_languages:
4730
+ skipped_languages.append(language)
4731
+ continue
4706
4732
  file_path = os.path.join(folder, filename)
4707
4733
  self.translate_xlf_file(file_path, base_language, libre_translate_api_server)
4734
+ if 0 < len(skipped_languages):
4735
+ self.log.log(f"The translation-service does not offer these languages, so their texts stay untranslated: {', '.join(skipped_languages)}.", LogLevel.Information)
4736
+
4737
+ @GeneralUtilities.check_arguments
4738
+ def get_supported_translation_languages(self, libre_translate_api_server: str) -> set[str]:
4739
+ """The languages the LibreTranslate-instance at the given address can translate into."""
4740
+ response = requests.get(f"{libre_translate_api_server.rstrip('/')}/languages", timeout=30)
4741
+ response.raise_for_status()
4742
+ return {language["code"] for language in response.json()}
4708
4743
 
4709
4744
  @GeneralUtilities.check_arguments
4710
4745
  def translate_xlf_file(self, file: str, base_language: str, libre_translate_api_server: str):
@@ -4822,6 +4857,7 @@ OCR-content:
4822
4857
  def is_runnning_in_container(self) ->bool:
4823
4858
  """this function is based on a convention and does not do a real check."""
4824
4859
  return os.environ.get("ISRUNNINGINCONTAINER") == "true"
4860
+
4825
4861
 
4826
4862
  @GeneralUtilities.check_arguments
4827
4863
  def is_running_in_build_container(self) ->bool:
@@ -1231,7 +1231,10 @@ class TFCPS_Tools_General:
1231
1231
  certificate_folder: str = os.path.join(resources_folder, resource_name)
1232
1232
 
1233
1233
  resource_content_filename: str = service_name+resource_name
1234
- certificate_file = os.path.join(certificate_folder, f"{domain}.crt")
1234
+ #the certificate-files are named after resource_content_filename and not after the domain (see the calls of
1235
+ #generate_certificate and sign_certificate below), so the existence-check has to use that name as well. With the
1236
+ #domain as the name it never found an existing certificate and therefore generated a new one on every run.
1237
+ certificate_file = os.path.join(certificate_folder, f"{resource_content_filename}.crt")
1235
1238
  unsignedcertificate_file = os.path.join(certificate_folder, f"{domain}.unsigned.crt")
1236
1239
  certificate_exists = os.path.exists(certificate_file)
1237
1240
  if certificate_exists:
@@ -1783,6 +1786,12 @@ class TFCPS_Tools_General:
1783
1786
  GeneralUtilities.ensure_file_exists(os.path.join(codeunit_folder, codeunit_name,"packages.lock.json"))
1784
1787
  GeneralUtilities.ensure_file_exists(os.path.join(codeunit_folder, codeunit_name+"Tests","packages.lock.json"))
1785
1788
  self.__sc.run_program_argsasarray("dotnet", ["restore", sln_file, "--force", "--force-evaluate"], codeunit_folder)
1789
+ #dotnet writes the lock-files with the line-endings of the operating-system it runs on, so the same dependencies produce a
1790
+ #different file on windows than on linux. The lock-files are committed, so that difference would show up as a change of the whole
1791
+ #file in every commit which was created on the other operating-system. They are therefore normalized to LF here, independent of
1792
+ #where the update ran.
1793
+ for lock_file in Path(codeunit_folder).rglob("packages.lock.json"):
1794
+ self.__sc.normalize_invisible_characters(str(lock_file))
1786
1795
 
1787
1796
  @GeneralUtilities.check_arguments
1788
1797
  def get_dependency_version_in_resources_folder(self, resources_folder:str, dependency_name: str) ->str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.31
3
+ Version: 4.4.33
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
@@ -12,7 +12,7 @@ ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1g
12
12
  ScriptCollection/RepositoryDiagramGenerator.py,sha256=K_u2NW_p4ozdWD50irJEkkcDVa70TcUJpZN63TeXSLw,7092
13
13
  ScriptCollection/RepositoryHistoryAnalyzer.py,sha256=rD8eC5lMUe5MHmCBHfYft_G-N9IbvtsFGkU7EMwPjrY,5779
14
14
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
15
- ScriptCollection/ScriptCollectionCore.py,sha256=equQ2c2EpHDlp9-o6vX8ThfiL_0UJKQsAh3vIaQF3yQ,296980
15
+ ScriptCollection/ScriptCollectionCore.py,sha256=dPllLFFnW9iYiKKzLKQgr8Bznn5yJbSJv0LVKLTFyJA,300265
16
16
  ScriptCollection/TestKind.py,sha256=EBTLR8yBz5VmWA2NZIpDTbQNg6tkfv_kAsIzEJ--mCI,1756
17
17
  ScriptCollection/UnassignedVariablesCheck.py,sha256=8xNcp1D5HeOLO1a1NEerq2TsnpFhw7yzYPkaay-oisY,3804
18
18
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,7 +45,7 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=oYEhz5ZWMnbu97_CcYEqdDxakUF
45
45
  ScriptCollection/TFCPS/TFCPS_OCIImageSecretScan.py,sha256=rhw0glr4gZ5enG9faOD51xE4MMK1cIdNjUdaswiMsrY,14622
46
46
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=XLVsFTA1jvfDbZ7wYJgIdEByZhF_bYVbA5jkisuvK4k,2322
47
47
  ScriptCollection/TFCPS/TFCPS_RemoteBuild.py,sha256=2Tx5HLk1ZftBWDCTiGZdP2QiiGNyWsEuTCSt33dNQjc,23891
48
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=y452sky-RdP__jHqewUvU1rUgJZM68sMZgOQkmSchtI,156175
48
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=d_gCL3ExRoNgerQwEzc2qoY6wG3ZEUqw-ZT6Xb6C_xs,157127
49
49
  ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py,sha256=6_63udxHnPlu_TMk_ftLZTnzriJO8MCxVCVAsweZqHs,37073
50
50
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  ScriptCollection/TFCPS/CPP/TFCPS_CodeUnitSpecific_CPP.py,sha256=BNZPMjGiWLMBH7QDtP06WEVLMnI38NLX4Dpd13bSbi4,16614
@@ -71,8 +71,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
71
71
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=5z990qyO5durX07xRWRwju1hl6wpjQAy2f-yRwJ-7s0,11856
73
73
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- scriptcollection-4.4.31.dist-info/METADATA,sha256=rRsrPv4VZbIyRLyv53uQ6jqDWPkDm7BYnWy3zG3cYew,7690
75
- scriptcollection-4.4.31.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
- scriptcollection-4.4.31.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
- scriptcollection-4.4.31.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
- scriptcollection-4.4.31.dist-info/RECORD,,
74
+ scriptcollection-4.4.33.dist-info/METADATA,sha256=xIuGndPfw4sZeWpdZAJiOGvhTxp8zU90WqkB05nzYmo,7690
75
+ scriptcollection-4.4.33.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
76
+ scriptcollection-4.4.33.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
77
+ scriptcollection-4.4.33.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
78
+ scriptcollection-4.4.33.dist-info/RECORD,,