ScriptCollection 4.3.60__py3-none-any.whl → 4.3.61__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.60"
42
+ version = "4.3.61"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -3057,6 +3057,16 @@ TXDX
3057
3057
  def create_local_docker_network(self, network_name: str) -> None:
3058
3058
  self.run_program("docker", f"network create {network_name}")
3059
3059
 
3060
+ @GeneralUtilities.check_arguments
3061
+ def format_json_file(self, file: str, indentation: int = 2) -> None:
3062
+ """Reformats the given json-file with the given indentation. The order of the properties is kept
3063
+ because in json-files which are used as configuration the order is usually chosen intentionally."""
3064
+ encoding = "utf-8"
3065
+ content = json.loads(GeneralUtilities.read_text_from_file(file, encoding))
3066
+ formatted_content = json.dumps(content, indent=indentation, sort_keys=False, ensure_ascii=False)
3067
+ GeneralUtilities.write_text_to_file(file, formatted_content.rstrip("\n") + "\n", encoding)
3068
+ self.normalize_line_endings(file)
3069
+
3060
3070
  @GeneralUtilities.check_arguments
3061
3071
  def format_xml_file(self, file: str,add_xml_declaration:bool=True) -> None:
3062
3072
  encoding = "utf-8"
@@ -3691,6 +3701,34 @@ OCR-content:
3691
3701
  self.run_with_epew("vl2svg",argument,workingfolder,encode_argument_in_base64=True)
3692
3702
  #this uses vega-light. to use vega "vg2svg" should be used instead.
3693
3703
 
3704
+ @GeneralUtilities.check_arguments
3705
+ def add_tooltips_to_chart_diagram(self, svg_file: str) -> int:
3706
+ """Adds a title-element to each data-point of a chart-diagram which was generated by generate_chart_diagram
3707
+ and returns the amount of data-points which were processed. Svg-viewers which support user-interaction (for
3708
+ example browsers) show the content of a title-element as tooltip while the mouse hovers over the according
3709
+ element. This is required because the tooltips which are defined in a vega-lite-specification are only
3710
+ available when the diagram is rendered by the vega-runtime inside a website, while the generated svg-file
3711
+ is static and does not contain that runtime. The content of the tooltip is the accessibility-label which
3712
+ vega already generates for the data-point and which contains the values of all encoded fields.
3713
+ Only data-points of symbol-marks are processed; for other mark-types (for example bars) the according
3714
+ role-description would have to be added."""
3715
+ encoding = "utf-8"
3716
+ svg_namespace = "http://www.w3.org/2000/svg"
3717
+ root = ET.XML(GeneralUtilities.read_text_from_file(svg_file, encoding))
3718
+ result = 0
3719
+ for element in root.iter():
3720
+ if element.get("aria-roledescription") != "point":
3721
+ continue
3722
+ label = element.get("aria-label")
3723
+ if label is None:
3724
+ continue
3725
+ title = ET.Element(f"{{{svg_namespace}}}title")
3726
+ title.text = label
3727
+ element.insert(0, title)#the title-element must be the first child-element of the element it describes
3728
+ result = result+1
3729
+ GeneralUtilities.write_text_to_file(svg_file, ET.tostring(root, encoding="unicode"), encoding)
3730
+ return result
3731
+
3694
3732
  @GeneralUtilities.check_arguments
3695
3733
  def inspect_container(self, container_name: str) :
3696
3734
  program_result = self.run_program(
@@ -232,7 +232,13 @@ class TFCPS_CodeUnit_BuildCodeUnits:
232
232
  @GeneralUtilities.check_arguments
233
233
  def __normalize_line_endings_of_common_files(self) -> None:
234
234
  #TODO add option to define exceptions (means: files which should not be normalized).
235
- self.sc.normalize_line_endings_of_files_in_folder(self.repository, ["txt", "md", "json", "xml", "csv", "yml", "yaml", "gitignore"])
235
+ self.sc.format_xml_file(os.path.join(self.repository, ".ScriptCollection", "ProductInformation.xml"))
236
+ for codeunit in self.tfcps_tools_general.get_codeunits(self.repository):
237
+ self.sc.format_xml_file(os.path.join(self.repository, codeunit, f"{codeunit}.codeunit.xml"))
238
+ workspace_file = os.path.join(self.repository, f"{self.tfcps_tools_general.get_product_name(self.repository)}.code-workspace")
239
+ if os.path.isfile(workspace_file):
240
+ self.sc.format_json_file(workspace_file)
241
+ self.sc.normalize_line_endings_of_files_in_folder(self.repository, ["txt", "md", "json", "xml", "csv", "yml", "yaml", "toml","gitignore", "gitattributes", "code-workspace"])
236
242
 
237
243
  @GeneralUtilities.check_arguments
238
244
  def is_working_branch(self)->bool:
@@ -456,25 +462,28 @@ class TFCPS_CodeUnit_BuildCodeUnits:
456
462
  "x": {
457
463
  "field": "Timestamp",
458
464
  "type": "temporal",
459
- "title": "Date"
465
+ "title": "Date",
466
+ "scale": {
467
+ "type": "utc"#render the ticks in utc so the diagram looks the same independent of the timezone of the machine which builds it
468
+ },
469
+ "axis": {
470
+ "format": "%Y-%m-%d %H:%M:%S (UTC)",#everything which is not a format-specifier starting with a percent-sign is taken literally
471
+ "labelAngle": -45,#the timestamps are too long to be displayed horizontally next to each other
472
+ "labelLimit": 250,#without this the labels would be truncated with an ellipsis because they are longer than the default-limit of 180 pixels
473
+ "tickCount": 8
474
+ }
460
475
  },
461
476
  "y": {
462
477
  "field": "LinesOfCode",
463
478
  "type": "quantitative",
464
479
  "title": "Lines of Code"
465
480
  },
481
+ #the timestamp and the lines of code are not listed here although they are part of the tooltip: the fields which are encoded
482
+ #as x respectively as y are always part of the generated tooltip anyway, so listing them again would show them twice.
466
483
  "tooltip": [
467
484
  {
468
485
  "field": "Version",
469
486
  "type": "ordinal"
470
- },
471
- {
472
- "field": "LinesOfCode",
473
- "type": "quantitative"
474
- },
475
- {
476
- "field": "Timestamp",
477
- "type": "temporal"
478
487
  }
479
488
  ]
480
489
  }
@@ -492,6 +501,7 @@ class TFCPS_CodeUnit_BuildCodeUnits:
492
501
  GeneralUtilities.ensure_file_exists(diagram_svg_file)
493
502
  GeneralUtilities.assert_condition(not self.sc.file_is_git_ignored(f"Other/Reference/Technical/Diagrams/{filenamebase}.svg",self.repository),f"Other/Reference/Technical/Diagrams/{filenamebase}.svg must not be git-ignored")#because it should be referencable in markdown-files and viewable without building the codeunits.
494
503
  self.sc.generate_chart_diagram(diagram_definition_file,os.path.basename(diagram_svg_file))
504
+ self.sc.add_tooltips_to_chart_diagram(diagram_svg_file)#so the exact values of a data-point are visible when the svg-file is opened directly in a browser
495
505
  self.sc.format_xml_file(diagram_svg_file)
496
506
 
497
507
  @GeneralUtilities.check_arguments
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.60
3
+ Version: 4.3.61
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=kqKwoy86fDSc6YmU1pFTq7CPfUuTRTBgBJN7ldgjVI0,247435
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=-2uuSZc2m-gPq5FkDC13aHIaaRAVtmsijobxd0onhaQ,249975
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
@@ -38,7 +38,7 @@ ScriptCollection/TFCPS/SCTaskRunnerServer.py,sha256=rpuwSsQ6YQfZS2LGnvOH5ql8zs_-
38
38
  ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW1NOCMiLMzOy48OqlJX-KY,1744
39
39
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=N-Wvxzwv_R8EVybjQjE7wXX-VpFLa_62LinWa57C_Wo,35345
40
40
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=Ll5EOkpVpPiFrM2mLeQXolaF7075IwgtnHXvfdpkH4k,9904
41
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=TdyhK4KVMliYRs_kSCaKUfX6iOqYlj0uaiYbdwR0G5E,44683
41
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=9vnbC8Ag_anvOb6MZpbcMPg0MF04dWLIgheQ1YMEf7M,46133
42
42
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
43
43
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
44
44
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=zp7n0Li7GTi4tERDMgDcJ-o3m6131m31zvkat0lALEc,7781
@@ -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.60.dist-info/METADATA,sha256=qTuiVep93JcmjKYmIMfK1P0ado6xTK28zzWiDzGub6A,7648
71
- scriptcollection-4.3.60.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
72
- scriptcollection-4.3.60.dist-info/entry_points.txt,sha256=52v0Kt6uaeQeDFjvc0Xcsd4YqQw2qKcs6GNgPO71pkU,5996
73
- scriptcollection-4.3.60.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
74
- scriptcollection-4.3.60.dist-info/RECORD,,
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,,