ScriptCollection 3.5.155__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
@@ -367,11 +367,15 @@ class GeneralUtilities:
367
367
 
368
368
  @staticmethod
369
369
  @check_arguments
370
- def datetime_to_string_for_logfile_entry(datetime_object: datetime, add_timezone_info_to_log: bool = True) -> str:
371
- if add_timezone_info_to_log:
372
- return datetime_object.isoformat()
370
+ def datetime_to_string_for_logfile_entry(datetime_object: datetime, add_milliseconds: bool = False) -> str:
371
+ pattern: str = None
372
+ if add_milliseconds:
373
+ pattern = "%Y-%m-%dT%H:%M:%S.%f%z"
373
374
  else:
374
- return datetime_object.strftime("%Y-%m-%d %H:%M:%S")
375
+ pattern = "%Y-%m-%dT%H:%M:%S%z"
376
+ s = datetime_object.strftime(pattern)
377
+ s = s[:-2] + ":" + s[-2:]
378
+ return s
375
379
 
376
380
  @staticmethod
377
381
  @check_arguments
@@ -617,6 +621,10 @@ class GeneralUtilities:
617
621
  with open(file, "wb") as file_object:
618
622
  file_object.write(content)
619
623
 
624
+ @staticmethod
625
+ def is_binary_file(path:str):
626
+ return b'\x00' in GeneralUtilities.read_binary_from_file(path)
627
+
620
628
  @staticmethod
621
629
  @check_arguments
622
630
  def read_lines_from_file(file: str, encoding="utf-8") -> list[str]:
ScriptCollection/SCLog.py CHANGED
@@ -22,6 +22,7 @@ class SCLog:
22
22
  add_overhead_to_console: bool
23
23
  add_overhead_to_logfile: bool
24
24
  print_as_color: bool
25
+ add_milliseconds_to_logfile_entry: bool
25
26
 
26
27
  def __init__(self, log_file: str = None, loglevel: LogLevel = None, print_as_color: bool = True):
27
28
  self.log_file = log_file
@@ -31,6 +32,7 @@ class SCLog:
31
32
  self.loglevel = loglevel
32
33
  self.add_overhead_to_console = False
33
34
  self.add_overhead_to_logfile = False
35
+ self.add_milliseconds_to_logfile_entry = False
34
36
  self.print_as_color = print_as_color
35
37
 
36
38
  @GeneralUtilities.check_arguments
@@ -70,7 +72,7 @@ class SCLog:
70
72
 
71
73
  moment: datetime = datetime.now(datetime.now().astimezone().tzinfo)
72
74
 
73
- part1 = f"[{GeneralUtilities.datetime_to_string_for_logfile_entry(moment, True)}] ["
75
+ part1 = f"[{GeneralUtilities.datetime_to_string_for_logfile_entry(moment, self.add_milliseconds_to_logfile_entry)}] ["
74
76
  if loglevel == LogLevel.Information:
75
77
  part2 = f"Information"
76
78
  elif loglevel == LogLevel.Error:
@@ -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.155"
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
@@ -2629,12 +2629,6 @@ class TasksForCommonProjectStructure:
2629
2629
  project_version = self.get_version_of_project(repository_folder)
2630
2630
 
2631
2631
  now = datetime.now()
2632
- if not self.__suport_information_exists(repository_folder, project_version):
2633
- support_time = timedelta(days=365*2+30*3+1) # TODO make this configurable
2634
- until = now + support_time
2635
- until_day = datetime(until.year, until.month, until.day, 0, 0, 0)
2636
- from_day = datetime(now.year, now.month, now.day, 0, 0, 0)
2637
- self.mark_current_version_as_supported(repository_folder, project_version, from_day, until_day)
2638
2632
 
2639
2633
  project_resources_folder = os.path.join(repository_folder, "Other", "Scripts")
2640
2634
  PrepareBuildCodeunits_script_name = "PrepareBuildCodeunits.py"
@@ -2649,7 +2643,23 @@ class TasksForCommonProjectStructure:
2649
2643
  raise ValueError(f"PrepareBuildCodeunits.py resulted in exitcode {result[0]}.")
2650
2644
 
2651
2645
  self.__do_repository_checks(repository_folder, project_version)
2646
+ if not self.__suport_information_exists(repository_folder, project_version):
2647
+ support_time = timedelta(days=365*2+30*3+1) # TODO make this configurable
2648
+ until = now + support_time
2649
+ until_day = datetime(until.year, until.month, until.day, 0, 0, 0)
2650
+ from_day = datetime(now.year, now.month, now.day, 0, 0, 0)
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.155
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
@@ -0,0 +1,17 @@
1
+ ScriptCollection/CertificateUpdater.py,sha256=OAxrG21k_o3W3niOOGNSZzUPJlvolOWc1lRB2dMhc3g,9212
2
+ ScriptCollection/Executables.py,sha256=jfg8X22SxE2WkLhLHrB1ny4u32udEV8ORcw9b2aICcY,37570
3
+ ScriptCollection/GeneralUtilities.py,sha256=l2uEoh73ZGAx_0OTT7zr2FjqCuL3SEBVakq_FTj95zw,48183
4
+ ScriptCollection/ImageUpdater.py,sha256=qTe3yoqzQJY7LZdXBbjbWvrsSQaeHy1VwmOxaRzU2ig,29305
5
+ ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
6
+ ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
7
+ ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
8
+ ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
9
+ ScriptCollection/SCLog.py,sha256=rMdrEzBKQZBdObPJ9nZ5XCEXRoIFqPh8fAoiX6ZOVuw,4493
10
+ ScriptCollection/ScriptCollectionCore.py,sha256=m0r_oEirO8wmimxVwq5r-jvAyuaI7PPFap24AWv2Pxw,139775
11
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=TjGG7ZfP5TXXerx2Zc21cKT2zIbuE0MLub8YntGb1yo,247844
12
+ ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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
@@ -1,17 +0,0 @@
1
- ScriptCollection/CertificateUpdater.py,sha256=OAxrG21k_o3W3niOOGNSZzUPJlvolOWc1lRB2dMhc3g,9212
2
- ScriptCollection/Executables.py,sha256=BojgHGBYn5QqpsdIgn8r8raxb8bE_BUyb-fZ_rCEN0A,37050
3
- ScriptCollection/GeneralUtilities.py,sha256=E1Jjgf_Vdc8G4KhCSg7FnyP6R3jRNPpsUiZnjSQ-2zk,47962
4
- ScriptCollection/ImageUpdater.py,sha256=qTe3yoqzQJY7LZdXBbjbWvrsSQaeHy1VwmOxaRzU2ig,29305
5
- ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
6
- ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
7
- ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
8
- ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
9
- ScriptCollection/SCLog.py,sha256=49NlLEmK_f-icw_uEPq9U3qv-oBTMRcIqSg3jaO8VsA,4360
10
- ScriptCollection/ScriptCollectionCore.py,sha256=yLDK7zuBIW0K3y9tK53Bjt2zjEkLgEyKnDq4v0eo78k,139260
11
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=BGmhrkHPbSxo9CQYo1URbERROiDnJSEt5V-b1emX-wQ,247266
12
- ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- scriptcollection-3.5.155.dist-info/METADATA,sha256=Y0a-2LHPG_-uCQpwJgXZjMu5rJczHCqu_IXRpLhguxU,7689
14
- scriptcollection-3.5.155.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- scriptcollection-3.5.155.dist-info/entry_points.txt,sha256=yZlEK0r5Ie7xrSLdlWZgFqzLZiIctsIAUJvDCgrYBRo,4193
16
- scriptcollection-3.5.155.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
- scriptcollection-3.5.155.dist-info/RECORD,,