ScriptCollection 3.5.158__py3-none-any.whl → 3.5.160__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.
@@ -36,7 +36,7 @@ from .ProgramRunnerPopen import ProgramRunnerPopen
36
36
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
37
37
  from .SCLog import SCLog, LogLevel
38
38
 
39
- version = "3.5.158"
39
+ version = "3.5.160"
40
40
  __version__ = version
41
41
 
42
42
 
@@ -2469,7 +2469,7 @@ OCR-content:
2469
2469
  def get_lines_of_code_with_default_excluded_patterns(self, repository: str) -> int:
2470
2470
  return self.get_lines_of_code(repository, self.default_excluded_patterns_for_loc, False)
2471
2471
 
2472
- default_excluded_patterns_for_loc: list[str] = [".txt", ".md",".vscode", "Resources", "Reference", ".gitignore", ".gitattributes", "Other/Metrics"]
2472
+ default_excluded_patterns_for_loc: list[str] = [".txt", ".md", ".vscode", "Resources", "Reference", ".gitignore", ".gitattributes", "Other/Metrics"]
2473
2473
 
2474
2474
  def get_lines_of_code(self, repository: str, excluded_pattern: list[str], verbose: bool) -> int:
2475
2475
  self.assert_is_git_repository(repository)
@@ -2482,19 +2482,23 @@ OCR-content:
2482
2482
  if very_verbose:
2483
2483
  verbose = True
2484
2484
  for file in files:
2485
- if self.__is_excluded_by_glob_pattern(file, excluded_pattern):
2486
- if very_verbose:
2487
- GeneralUtilities.write_message_to_stdout(f"File '{file}' is ignored because it matches an excluded pattern.")
2488
- else:
2489
- full_file: str = os.path.join(repository, file)
2490
- if GeneralUtilities.is_binary_file(full_file):
2485
+ if os.path.isfile(os.path.join(repository, file)):
2486
+ if self.__is_excluded_by_glob_pattern(file, excluded_pattern):
2491
2487
  if very_verbose:
2492
- GeneralUtilities.write_message_to_stdout(f"File '{file}' is ignored because it is a binary-file.")
2488
+ GeneralUtilities.write_message_to_stdout(f"File '{file}' is ignored because it matches an excluded pattern.")
2493
2489
  else:
2494
- if verbose:
2495
- GeneralUtilities.write_message_to_stdout(f"Count lines of file '{file}'.")
2496
- length = len(GeneralUtilities.read_nonempty_lines_from_file(full_file))
2497
- result = result+length
2490
+ full_file: str = os.path.join(repository, file)
2491
+ if GeneralUtilities.is_binary_file(full_file):
2492
+ if very_verbose:
2493
+ GeneralUtilities.write_message_to_stdout(f"File '{file}' is ignored because it is a binary-file.")
2494
+ else:
2495
+ if verbose:
2496
+ GeneralUtilities.write_message_to_stdout(f"Count lines of file '{file}'.")
2497
+ length = len(GeneralUtilities.read_nonempty_lines_from_file(full_file))
2498
+ result = result+length
2499
+ else:
2500
+ if verbose:
2501
+ GeneralUtilities.write_message_to_stdout(f"File '{file}' is ignored because it does not exist.")
2498
2502
  return result
2499
2503
 
2500
2504
  def __is_excluded_by_glob_pattern(self, file: str, excluded_patterns: list[str]) -> bool:
@@ -1827,15 +1827,60 @@ class TasksForCommonProjectStructure:
1827
1827
  coverage_file_relative = f"{test_coverage_folder_relative}/TestCoverage.xml"
1828
1828
  coverage_file = GeneralUtilities.resolve_relative_path(coverage_file_relative, codeunit_folder)
1829
1829
  self.run_with_epew("lcov_cobertura", f"coverage/lcov.info --base-dir . --excludes test --output ../{coverage_file_relative} --demangle", src_folder, verbosity)
1830
+
1831
+ # format correctly
1830
1832
  content = GeneralUtilities.read_text_from_file(coverage_file)
1831
1833
  content = re.sub('<![^<]+>', '', content)
1832
1834
  content = re.sub('\\\\', '/', content)
1833
1835
  content = re.sub('\\ name=\\"lib\\"', '', content)
1834
- content = re.sub('<package ', f'<package name="{codeunit_name}" ', content)
1835
1836
  content = re.sub('\\ filename=\\"lib/', f' filename="{package_name}/lib/', content)
1836
1837
  GeneralUtilities.write_text_to_file(coverage_file, content)
1838
+ self.__testcoverage_for_flutter_project_merge_packages(coverage_file)
1839
+ self.__testcoverage_for_flutter_project_calculate_line_rate(coverage_file)
1840
+
1837
1841
  self.run_testcases_common_post_task(repository_folder, codeunit_name, verbosity, generate_badges, build_environment_target_type, args)
1838
1842
 
1843
+ def __testcoverage_for_flutter_project_merge_packages(self, coverage_file: str):
1844
+ tree = etree.parse(coverage_file)
1845
+ root = tree.getroot()
1846
+
1847
+ packages = root.findall("./packages/package")
1848
+
1849
+ all_classes = []
1850
+ for pkg in packages:
1851
+ classes = pkg.find("classes")
1852
+ if classes is not None:
1853
+ all_classes.extend(classes.findall("class"))
1854
+ new_package = etree.Element("package", name="Malno")
1855
+ new_classes = etree.SubElement(new_package, "classes")
1856
+ for cls in all_classes:
1857
+ new_classes.append(cls)
1858
+ packages_node = root.find("./packages")
1859
+ packages_node.clear()
1860
+ packages_node.append(new_package)
1861
+ tree.write(coverage_file, pretty_print=True, xml_declaration=True, encoding="UTF-8")
1862
+
1863
+ def __testcoverage_for_flutter_project_calculate_line_rate(self, coverage_file: str):
1864
+ tree = etree.parse(coverage_file)
1865
+ root = tree.getroot()
1866
+ package = root.find("./packages/package")
1867
+ if package is None:
1868
+ raise RuntimeError("No <package>-Element found")
1869
+
1870
+ line_elements = package.findall(".//line")
1871
+
1872
+ amount_of_lines = 0
1873
+ amount_of_hited_lines = 0
1874
+
1875
+ for line in line_elements:
1876
+ amount_of_lines += 1
1877
+ hits = int(line.get("hits", "0"))
1878
+ if hits > 0:
1879
+ amount_of_hited_lines += 1
1880
+ line_rate = amount_of_hited_lines / amount_of_lines if amount_of_lines > 0 else 0.0
1881
+ package.set("line-rate", str(line_rate))
1882
+ tree.write(coverage_file, pretty_print=True, xml_declaration=True, encoding="UTF-8")
1883
+
1839
1884
  @GeneralUtilities.check_arguments
1840
1885
  def standardized_tasks_run_testcases_for_angular_codeunit(self, runtestcases_script_file: str, build_environment_target_type: str, generate_badges: bool, verbosity: int, commandline_arguments: list[str]) -> None:
1841
1886
  # prepare
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 3.5.158
3
+ Version: 3.5.160
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Home-page: https://github.com/anionDev/ScriptCollection
6
6
  Author: Marius Göcke
@@ -7,11 +7,11 @@ ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4b
7
7
  ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
8
8
  ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
9
9
  ScriptCollection/SCLog.py,sha256=rMdrEzBKQZBdObPJ9nZ5XCEXRoIFqPh8fAoiX6ZOVuw,4493
10
- ScriptCollection/ScriptCollectionCore.py,sha256=zm3KiuLoFiz99JZkqUkPhnKVhKD24bDqxpUiAplON24,141383
11
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=nXhwH6rfA-XXdQVXYQoxXUQ5sA82d1bDF2EVKdZIfo8,248595
10
+ ScriptCollection/ScriptCollectionCore.py,sha256=vFP4e2ksl982hDKgQuC5udmBIG6Wu7m6MHG5PFa3_k8,141662
11
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=6Id8KRtSIuUnbPakmyNutnpF5kHwaAFkzPpxD5csYs0,250347
12
12
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- scriptcollection-3.5.158.dist-info/METADATA,sha256=RLxzi_qgfzjf-_uC_-neTKRG22TJhJK5VKyDRg2SplU,7689
14
- scriptcollection-3.5.158.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- scriptcollection-3.5.158.dist-info/entry_points.txt,sha256=EBRDrnGDURysHNyK0Z0fPCnL7uCCO_Mxc6WYJ47KxAI,4234
16
- scriptcollection-3.5.158.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
- scriptcollection-3.5.158.dist-info/RECORD,,
13
+ scriptcollection-3.5.160.dist-info/METADATA,sha256=ZIoWVimoMYzMsReojXoop-Wao1qioWzZwe6w6yM06xE,7689
14
+ scriptcollection-3.5.160.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ scriptcollection-3.5.160.dist-info/entry_points.txt,sha256=EBRDrnGDURysHNyK0Z0fPCnL7uCCO_Mxc6WYJ47KxAI,4234
16
+ scriptcollection-3.5.160.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
+ scriptcollection-3.5.160.dist-info/RECORD,,