ScriptCollection 3.5.156__py3-none-any.whl → 3.5.157__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.
@@ -760,3 +760,17 @@ def UpdateTimestampInFile() -> int:
760
760
  sc = ScriptCollectionCore()
761
761
  sc.update_timestamp_in_file(args.file)
762
762
  return 0
763
+
764
+
765
+ def LOC() -> int:
766
+ parser = argparse.ArgumentParser(description="Counts the lines of code in a git-repository")
767
+ parser.add_argument('-r', '--repository', required=True)
768
+ args = parser.parse_args()
769
+ sc = ScriptCollectionCore()
770
+ folder: str = None
771
+ if os.path.isabs(args.repository):
772
+ folder = args.repository
773
+ else:
774
+ folder = GeneralUtilities.resolve_relative_path(args.repository, os.getcwd())
775
+ GeneralUtilities.write_message_to_stdout(sc.get_lines_of_code(folder))
776
+ return 0
@@ -621,6 +621,10 @@ class GeneralUtilities:
621
621
  with open(file, "wb") as file_object:
622
622
  file_object.write(content)
623
623
 
624
+ @staticmethod
625
+ def is_binary_file(path:str):
626
+ return b'\x00' in GeneralUtilities.read_binary_from_file(path)
627
+
624
628
  @staticmethod
625
629
  @check_arguments
626
630
  def read_lines_from_file(file: str, encoding="utf-8") -> list[str]:
@@ -35,7 +35,7 @@ from .ProgramRunnerPopen import ProgramRunnerPopen
35
35
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
36
36
  from .SCLog import SCLog, LogLevel
37
37
 
38
- version = "3.5.156"
38
+ version = "3.5.157"
39
39
  __version__ = version
40
40
 
41
41
 
@@ -2464,3 +2464,14 @@ OCR-content:
2464
2464
  return 1
2465
2465
  finally:
2466
2466
  self.log.log(f"Finished action \"{name_of_task}\".", LogLevel.Information)
2467
+
2468
+ def get_lines_of_code(self,repository:str)->int:
2469
+ self.assert_is_git_repository(repository)
2470
+ result:int=0
2471
+ result=self.run_program("git","ls-files",repository)
2472
+ files:list[str]=GeneralUtilities.string_to_lines(result[1])
2473
+ for file in files:
2474
+ full_file:str=os.path.join(repository,file)
2475
+ if not GeneralUtilities.is_binary_file(full_file):
2476
+ result=result+len(GeneralUtilities.read_nonempty_lines_from_file(full_file))
2477
+ return result
@@ -2650,6 +2650,16 @@ class TasksForCommonProjectStructure:
2650
2650
  from_day = datetime(now.year, now.month, now.day, 0, 0, 0)
2651
2651
  self.mark_current_version_as_supported(repository_folder, project_version, from_day, until_day)
2652
2652
  self.build_specific_codeunits(repository_folder, codeunits, verbosity, target_environmenttype, additional_arguments_file, is_pre_merge, export_target_directory, False, commandline_arguments, do_git_clean_when_no_changes, note)
2653
+ self.__save_lines_of_code(repository_folder)
2654
+
2655
+ @GeneralUtilities.check_arguments
2656
+ def __save_lines_of_code(self, repository_folder: str) -> None:
2657
+ loc = self.__sc.get_lines_of_code(repository_folder)
2658
+ loc_metric_folder = os.path.join(repository_folder, "Other", "Metrics")
2659
+ GeneralUtilities.ensure_directory_exists(loc_metric_folder)
2660
+ loc_metric_file = os.path.join(loc_metric_folder, "LinesOfCode.txt")
2661
+ GeneralUtilities.ensure_file_exists(loc_metric_file)
2662
+ GeneralUtilities.write_text_to_file(loc_metric_file, str(loc))
2653
2663
 
2654
2664
  @GeneralUtilities.check_arguments
2655
2665
  def build_specific_codeunits(self, repository_folder: str, codeunits: list[str], verbosity: int = 1, target_environmenttype: str = "QualityCheck", additional_arguments_file: str = None, is_pre_merge: bool = False, export_target_directory: str = None, assume_dependent_codeunits_are_already_built: bool = True, commandline_arguments: list[str] = [], do_git_clean_when_no_changes: bool = False, note: str = None, check_for_new_files: bool = True) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 3.5.156
3
+ Version: 3.5.157
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
@@ -23,8 +23,8 @@ Classifier: Topic :: Utilities
23
23
  Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
25
  Requires-Dist: build>=1.3.0
26
- Requires-Dist: coverage>=7.10.5
27
- Requires-Dist: cyclonedx-bom>=7.0.0
26
+ Requires-Dist: coverage>=7.10.6
27
+ Requires-Dist: cyclonedx-bom>=7.1.0
28
28
  Requires-Dist: defusedxml>=0.7.1
29
29
  Requires-Dist: keyboard>=0.13.5
30
30
  Requires-Dist: lcov-cobertura>=2.1.1
@@ -37,11 +37,11 @@ Requires-Dist: Pygments>=2.19.2
37
37
  Requires-Dist: pylint>=3.3.8
38
38
  Requires-Dist: pyOpenSSL>=25.1.0
39
39
  Requires-Dist: PyPDF>=6.0.0
40
- Requires-Dist: pytest>=8.4.1
40
+ Requires-Dist: pytest>=8.4.2
41
41
  Requires-Dist: PyYAML>=6.0.2
42
42
  Requires-Dist: qrcode>=8.2
43
43
  Requires-Dist: send2trash>=1.8.3
44
- Requires-Dist: twine>=6.1.0
44
+ Requires-Dist: twine>=6.2.0
45
45
  Requires-Dist: xmlschema>=4.1.0
46
46
 
47
47
  # ScriptCollection
@@ -1,17 +1,17 @@
1
1
  ScriptCollection/CertificateUpdater.py,sha256=OAxrG21k_o3W3niOOGNSZzUPJlvolOWc1lRB2dMhc3g,9212
2
- ScriptCollection/Executables.py,sha256=BojgHGBYn5QqpsdIgn8r8raxb8bE_BUyb-fZ_rCEN0A,37050
3
- ScriptCollection/GeneralUtilities.py,sha256=OaecNA7tTFlFA8Wu1dDVspug3DRaRRGbJy4AbpwudpQ,48055
2
+ ScriptCollection/Executables.py,sha256=jfg8X22SxE2WkLhLHrB1ny4u32udEV8ORcw9b2aICcY,37570
3
+ ScriptCollection/GeneralUtilities.py,sha256=l2uEoh73ZGAx_0OTT7zr2FjqCuL3SEBVakq_FTj95zw,48183
4
4
  ScriptCollection/ImageUpdater.py,sha256=qTe3yoqzQJY7LZdXBbjbWvrsSQaeHy1VwmOxaRzU2ig,29305
5
5
  ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
6
6
  ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
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=Rlj0JQG84M1NcsXOKmqJPW3_tkCOJquPreCYTx0Ne4E,139260
11
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=c4Ohfh8eQK68ObaC2YirTpNy8bht_uHhvxSGQXRgmiQ,247266
10
+ ScriptCollection/ScriptCollectionCore.py,sha256=m0r_oEirO8wmimxVwq5r-jvAyuaI7PPFap24AWv2Pxw,139775
11
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=TjGG7ZfP5TXXerx2Zc21cKT2zIbuE0MLub8YntGb1yo,247844
12
12
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- scriptcollection-3.5.156.dist-info/METADATA,sha256=pXOv4nagWda_5f1tY4A9uqhtBBtlqh4FU-9xUfxMa_Q,7689
14
- scriptcollection-3.5.156.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- scriptcollection-3.5.156.dist-info/entry_points.txt,sha256=yZlEK0r5Ie7xrSLdlWZgFqzLZiIctsIAUJvDCgrYBRo,4193
16
- scriptcollection-3.5.156.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
- scriptcollection-3.5.156.dist-info/RECORD,,
13
+ scriptcollection-3.5.157.dist-info/METADATA,sha256=93r89YmBKkaLd_J5cFRDocPZ56HH0ff6sQbVhZFmgds,7689
14
+ scriptcollection-3.5.157.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ scriptcollection-3.5.157.dist-info/entry_points.txt,sha256=EBRDrnGDURysHNyK0Z0fPCnL7uCCO_Mxc6WYJ47KxAI,4234
16
+ scriptcollection-3.5.157.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
+ scriptcollection-3.5.157.dist-info/RECORD,,
@@ -32,6 +32,7 @@ scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
32
32
  schealthcheck = ScriptCollection.Executables:Healthcheck
33
33
  sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
34
34
  sclistfoldercontent = ScriptCollection.Executables:ListFolderContent
35
+ scloc = ScriptCollection.Executables:LOC
35
36
  scmergepdfs = ScriptCollection.Executables:MergePDFs
36
37
  scnpmi = ScriptCollection.Executables:NpmI
37
38
  scobfuscatefilesfolder = ScriptCollection.Executables:ObfuscateFilesFolder