ScriptCollection 4.2.141__py3-none-any.whl → 4.2.143__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.
@@ -1148,6 +1148,17 @@ def RunCommandInFolder() -> int:
1148
1148
  return sc.run_command_in_folder(args.basefolder, args.command, args.arguments, args.actualfolder, args.excludedfolder)
1149
1149
 
1150
1150
 
1151
+ def RemoveTrailingLinebreak() -> int:
1152
+ parser = argparse.ArgumentParser(description="Removes the trailing linebreak from a file. If the last character is not a linebreak, the file is not modified.")
1153
+ parser.add_argument('-p', '--path', required=True, help="Path to the file.")
1154
+ args = parser.parse_args()
1155
+ if not os.path.isfile(args.path):
1156
+ GeneralUtilities.write_message_to_stderr(f"File '{args.path}' does not exist.")
1157
+ return 1
1158
+ ScriptCollectionCore().remove_trailing_linebreak(args.path)
1159
+ return 0
1160
+
1161
+
1151
1162
  def SyncXlfFiles()->int:
1152
1163
  parser = argparse.ArgumentParser(description="This function syncs the content of xlf-files in a folder. This is useful to keep the content of xlf-files in sync which are used for translations in software projects.")
1153
1164
  parser.add_argument('-p', '--prefix', required=True, help="File prefix. Example: 'message' when the files are named 'message.xlf', 'message.fr.xlf', etc.")
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
38
38
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
39
  from .SCLog import SCLog, LogLevel
40
40
 
41
- version = "4.2.141"
41
+ version = "4.2.143"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -2762,6 +2762,14 @@ TXDX
2762
2762
  if normalized_content != content:
2763
2763
  GeneralUtilities.write_binary_to_file(file, normalized_content)
2764
2764
 
2765
+ @GeneralUtilities.check_arguments
2766
+ def remove_trailing_linebreak(self, file: str) -> None:
2767
+ content = GeneralUtilities.read_binary_from_file(file)
2768
+ if content.endswith(b"\r\n"):
2769
+ GeneralUtilities.write_binary_to_file(file, content[:-2])
2770
+ elif content.endswith(b"\n") or content.endswith(b"\r"):
2771
+ GeneralUtilities.write_binary_to_file(file, content[:-1])
2772
+
2765
2773
  @GeneralUtilities.check_arguments
2766
2774
  def format_html_content(self, content: str, add_html_declaration: bool = False) -> str:
2767
2775
 
@@ -29,6 +29,11 @@ class TFCPS_Tools_General:
29
29
  # Relative path (inside the source-repository and inside the ScriptCollection.Resources-package) of the
30
30
  # file that pins the OpenAPIGenerator-version used as default when no repository-specific version is given.
31
31
  __openapigenerator_version_resource_relative_path:str="Dependencies/OpenAPIGenerator/Version.txt"
32
+ # Font used for rendering all PlantUML-diagrams. Pinning it makes the resulting SVG identical across machines
33
+ # (PlantUML's default 'sans-serif' otherwise resolves to different host-fonts on Windows vs Linux, which changes
34
+ # the computed text-lengths and coordinates and thus produces spurious diffs). The font is available in the
35
+ # build-image via the apt-package 'fonts-dejavu'.
36
+ __default_diagram_font_name:str="DejaVu Sans"
32
37
 
33
38
  def __init__(self,sc:ScriptCollectionCore):
34
39
  self.__sc=sc
@@ -640,15 +645,23 @@ class TFCPS_Tools_General:
640
645
 
641
646
  @GeneralUtilities.check_arguments
642
647
  def __generate_svg_files_from_plantuml(self, diagrams_files_folder: str, plantuml_jar_file: str) -> None:
643
- for file in GeneralUtilities.get_all_files_of_folder(diagrams_files_folder):
644
- if file.endswith(".plantuml"):
645
- output_filename = self.get_output_filename_for_plantuml_filename(file)
646
- argument = ['-jar',plantuml_jar_file, '-tsvg', os.path.basename(file)]
647
- folder = os.path.dirname(file)
648
- self.__sc.run_program_argsasarray("java", argument, folder)
649
- result_file = folder+"/" + output_filename
650
- GeneralUtilities.assert_file_exists(result_file)
651
- self.__sc.format_xml_file(result_file)
648
+ # Pin the font for all rendered diagrams via a PlantUML-config-file so the resulting SVG is identical across
649
+ # machines, without having to add a skinparam to every (also hand-written) .plantuml-file. See the comment at
650
+ # __default_diagram_font_name for the reason.
651
+ font_config_file = os.path.join(tempfile.gettempdir(), f"plantuml-font-config-{uuid.uuid4()}.cfg")
652
+ GeneralUtilities.write_text_to_file(font_config_file, f'skinparam defaultFontName "{TFCPS_Tools_General.__default_diagram_font_name}"')
653
+ try:
654
+ for file in GeneralUtilities.get_all_files_of_folder(diagrams_files_folder):
655
+ if file.endswith(".plantuml"):
656
+ output_filename = self.get_output_filename_for_plantuml_filename(file)
657
+ argument = ['-jar',plantuml_jar_file, '-tsvg', '-config', font_config_file, os.path.basename(file)]
658
+ folder = os.path.dirname(file)
659
+ self.__sc.run_program_argsasarray("java", argument, folder)
660
+ result_file = folder+"/" + output_filename
661
+ GeneralUtilities.assert_file_exists(result_file)
662
+ self.__sc.format_xml_file(result_file)
663
+ finally:
664
+ GeneralUtilities.ensure_file_does_not_exist(font_config_file)
652
665
 
653
666
  @GeneralUtilities.check_arguments
654
667
  def get_output_filename_for_plantuml_filename(self, plantuml_file: str) -> str:
@@ -670,7 +683,7 @@ class TFCPS_Tools_General:
670
683
  lines = ["@startuml CodeUnits-Overview"]
671
684
  # Pin font so the rendered SVG is byte-identical across machines (Java/PlantUML's
672
685
  # default 'sans-serif' otherwise resolves to different host fonts on Windows vs Linux).
673
- lines.append('skinparam defaultFontName "DejaVu Sans"')
686
+ lines.append(f'skinparam defaultFontName "{TFCPS_Tools_General.__default_diagram_font_name}"')
674
687
  lines.append(f"title CodeUnits of {project_name}")
675
688
 
676
689
  codeunits = self.get_codeunits(repository_folder)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.141
3
+ Version: 4.2.143
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
@@ -22,7 +22,7 @@ Classifier: Topic :: Utilities
22
22
  Requires-Python: >=3.11
23
23
  Description-Content-Type: text/markdown
24
24
  Requires-Dist: build>=1.5.0
25
- Requires-Dist: coverage>=7.14.1
25
+ Requires-Dist: coverage>=7.14.2
26
26
  Requires-Dist: cyclonedx-bom>=7.1.0
27
27
  Requires-Dist: defusedxml>=0.7.1
28
28
  Requires-Dist: keyboard>=0.13.5
@@ -35,7 +35,7 @@ Requires-Dist: pycdlib>=1.16.0
35
35
  Requires-Dist: Pygments>=2.20.0
36
36
  Requires-Dist: pylint>=4.0.6
37
37
  Requires-Dist: pyOpenSSL>=25.3.0
38
- Requires-Dist: PyPDF>=6.13.2
38
+ Requires-Dist: PyPDF>=6.13.3
39
39
  Requires-Dist: pytest>=8.4.2
40
40
  Requires-Dist: PyYAML>=6.0.3
41
41
  Requires-Dist: qrcode>=8.2.0
@@ -1,6 +1,6 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=vg1lZ6D1nqq_mO7iYTDSktSImXd34scfPaXiIrbvrg0,11848
2
2
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
3
- ScriptCollection/Executables.py,sha256=-xsbCfQEwGYBIkr6EKGe9qjFwDYDj7_BjFNXgUnIw4E,61402
3
+ ScriptCollection/Executables.py,sha256=TkAzd2_nfRdqiUR_QG2uGFcdbxOqpmslJBpOiBZcz0M,61938
4
4
  ScriptCollection/GeneralUtilities.py,sha256=cJK18rWzmVT3KyvjIAbPK4o4-jVPwYeuVpizbTHjBDc,68136
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=yYaC95h40uszuZPggn2kK3qXIN2ZjGMCavo-NQ53ElQ,1537
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=Z-HhC_CRtU3HdQflNsabFh9IJOucHcXmxMDcf58fli0,4671
12
- ScriptCollection/ScriptCollectionCore.py,sha256=tWTdHA0yC4lSBMgCstxJYuwiYt1tl1-COYUa5dxNLpk,217136
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=IfOU4a2JEtpeUYrpv_nVGITK3IC6GQCT_2snKJ2lmS0,217549
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=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
@@ -34,7 +34,7 @@ ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIu
34
34
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=BsSV4a-NZY86MZ20d-_rYxNVAI4UzAfmEwXlRZ8qWQc,7685
35
35
  ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=QRm8n1qH8H_XbJhGCbzwdNr9KSEy0WkbG7ulpc4Md3U,22696
36
36
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=JYiDqDsfVJQWS9xWMi_UzfXnXsJRnPRxAzFr82bUEvI,2370
37
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=srsEawFeFHsGyEDQElDvHH9fV6tlEPVdXJcTZv0L2a8,114073
37
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=Ui_jZpTL9CW0DSkpokLI0MUkdH4dTUH2ymDCc8pRSxc,115268
38
38
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=wS2yzYUmJ4m0cf6cBYVTHsiXSXfYhHoLFFy8x6yEQvY,19573
40
40
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -55,8 +55,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK
55
55
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
57
57
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- scriptcollection-4.2.141.dist-info/METADATA,sha256=nL4RtugOkry8oj2ijNnxB9BZ-pf4ALb014AdQdcyWHk,7817
59
- scriptcollection-4.2.141.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
- scriptcollection-4.2.141.dist-info/entry_points.txt,sha256=kUHH9H7MmheMRWvygzYBAw76GwbBKKsSWLyWI-nnNKw,5292
61
- scriptcollection-4.2.141.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
62
- scriptcollection-4.2.141.dist-info/RECORD,,
58
+ scriptcollection-4.2.143.dist-info/METADATA,sha256=XiZBTRJ63csd7tY8dKo5WHKmMc-3OxdTDyhKhfBza08,7817
59
+ scriptcollection-4.2.143.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
+ scriptcollection-4.2.143.dist-info/entry_points.txt,sha256=IUIlg0se3DubH9yuMrFE0sl92BXPdCqCPt0N7uGASs4,5373
61
+ scriptcollection-4.2.143.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
62
+ scriptcollection-4.2.143.dist-info/RECORD,,
@@ -56,6 +56,7 @@ screclaimspacefromdocker = ScriptCollection.Executables:ReclaimSpaceFromDocker
56
56
  scregexreplaceinfile = ScriptCollection.Executables:RegexReplaceInFile
57
57
  scremovefile = ScriptCollection.Executables:RemoveFile
58
58
  scremovefolder = ScriptCollection.Executables:RemoveFolder
59
+ scremovetrailinglinebreak = ScriptCollection.Executables:RemoveTrailingLinebreak
59
60
  screname = ScriptCollection.Executables:Rename
60
61
  screplacesubstringsinfilenames = ScriptCollection.Executables:ReplaceSubstringsInFilenames
61
62
  scruncommandinfolder = ScriptCollection.Executables:RunCommandInFolder