ScriptCollection 3.5.149__py3-none-any.whl → 3.5.151__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.
@@ -34,7 +34,7 @@ from .ProgramRunnerPopen import ProgramRunnerPopen
34
34
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
35
35
  from .SCLog import SCLog, LogLevel
36
36
 
37
- version = "3.5.149"
37
+ version = "3.5.151"
38
38
  __version__ = version
39
39
 
40
40
 
@@ -124,6 +124,17 @@ class TasksForCommonProjectStructure:
124
124
  sc.log = log
125
125
  self.__sc = sc
126
126
 
127
+ @GeneralUtilities.check_arguments
128
+ def is_codeunit_folder(self, codeunit_folder: str) -> bool:
129
+ repo_folder = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
130
+ if not self.__sc.is_git_repository(repo_folder):
131
+ return False
132
+ codeunit_name = os.path.basename(codeunit_folder)
133
+ codeunit_file: str = os.path.join(codeunit_folder, f"{codeunit_name}.codeunit.xml")
134
+ if not os.path.isfile(codeunit_file):
135
+ return False
136
+ return True
137
+
127
138
  @GeneralUtilities.check_arguments
128
139
  def assert_is_codeunit_folder(self, codeunit_folder: str) -> str:
129
140
  repo_folder = GeneralUtilities.resolve_relative_path("..", codeunit_folder)
@@ -474,8 +485,7 @@ class TasksForCommonProjectStructure:
474
485
  self.write_version_to_codeunit_file(codeunit_file, current_version)
475
486
 
476
487
  @GeneralUtilities.check_arguments
477
- def t4_transform(self, commontasks_script_file_of_current_file: str, verbosity: int):
478
- sc = ScriptCollectionCore()
488
+ def t4_transform(self, commontasks_script_file_of_current_file: str, verbosity: int,ignore_git_ignored_files:bool=True):
479
489
  codeunit_folder = GeneralUtilities.resolve_relative_path("../..", commontasks_script_file_of_current_file)
480
490
  self.__ensure_grylibrary_is_available(codeunit_folder)
481
491
  repository_folder: str = os.path.dirname(codeunit_folder)
@@ -483,9 +493,51 @@ class TasksForCommonProjectStructure:
483
493
  codeunit_folder = os.path.join(repository_folder, codeunitname)
484
494
  for search_result in Path(codeunit_folder).glob('**/*.tt'):
485
495
  tt_file = str(search_result)
486
- relative_path_to_tt_file = str(Path(tt_file).relative_to(codeunit_folder))
487
- argument = [f"--parameter=repositoryFolder={repository_folder}", f"--parameter=codeUnitName={codeunitname}", relative_path_to_tt_file]
488
- sc.run_program_argsasarray("t4", argument, codeunit_folder, verbosity=verbosity)
496
+ relative_path_to_tt_file_from_repository = str(Path(tt_file).relative_to(repository_folder))
497
+ if (not ignore_git_ignored_files) or (ignore_git_ignored_files and not self.__sc.file_is_git_ignored(relative_path_to_tt_file_from_repository,repository_folder)):
498
+ relative_path_to_tt_file_from_codeunit_file = str(Path(tt_file).relative_to(codeunit_folder))
499
+ argument = [f"--parameter=repositoryFolder={repository_folder}", f"--parameter=codeUnitName={codeunitname}", relative_path_to_tt_file_from_codeunit_file]
500
+ self.__sc.run_program_argsasarray("t4", argument, codeunit_folder, verbosity=verbosity)
501
+
502
+ @GeneralUtilities.check_arguments
503
+ def get_resource_from_global_resource(self,codeunit_folder:str,resource_name:str):
504
+ repository_folder:str= GeneralUtilities.resolve_relative_path("..", codeunit_folder)
505
+ source_folder:str=os.path.join(repository_folder,"Other","Resources",resource_name)
506
+ target_folder:str=os.path.join(codeunit_folder,"Other","Resources",resource_name)
507
+ GeneralUtilities.ensure_folder_exists_and_is_empty(target_folder)
508
+ GeneralUtilities.copy_content_of_folder(source_folder, target_folder)
509
+
510
+ @GeneralUtilities.check_arguments
511
+ def clone_repository_as_resource(self,local_repository_folder:str,remote_repository_link:str, resource_name:str,repository_subname:str=None)->str:
512
+ commit_id:str=None
513
+ target_folder:str=os.path.join(local_repository_folder,"Other","Resources",resource_name)
514
+ if repository_subname is not None:
515
+ target_folder=os.path.join(target_folder,repository_subname)
516
+ if not os.path.isdir(target_folder):
517
+ GeneralUtilities.ensure_directory_exists(target_folder)
518
+ GeneralUtilities.write_message_to_stdout(f"Clone {remote_repository_link} into {target_folder}...")
519
+ self.__sc.run_program("git",f"clone --recurse-submodules {remote_repository_link} {target_folder}")
520
+
521
+ self.__sc.git_get_commit_id(target_folder)
522
+
523
+ git_folders:list[str]=[]
524
+ git_files:list[str]=[]
525
+ for dirpath, dirnames, filenames in os.walk(target_folder):
526
+ for dirname in dirnames:
527
+ if dirname == ".git":
528
+ full_path = os.path.join(dirpath, dirname)
529
+ git_folders.append(full_path)
530
+ for filename in filenames:
531
+ if filename == ".git":
532
+ full_path = os.path.join(dirpath, filename)
533
+ git_files.append(full_path)
534
+ for git_folder in git_folders:
535
+ if os.path.isdir(git_folder):
536
+ GeneralUtilities.ensure_directory_does_not_exist(git_folder)
537
+ for git_file in git_files:
538
+ if os.path.isdir(git_file):
539
+ GeneralUtilities.ensure_file_does_not_exist(git_file)
540
+ return commit_id
489
541
 
490
542
  @GeneralUtilities.check_arguments
491
543
  def standardized_tasks_generate_reference_by_docfx(self, generate_reference_script_file: str, verbosity: int, targetenvironmenttype: str, commandline_arguments: list[str]) -> None:
@@ -1884,7 +1936,7 @@ class TasksForCommonProjectStructure:
1884
1936
  GeneralUtilities.write_text_to_file(file, result)
1885
1937
 
1886
1938
  @GeneralUtilities.check_arguments
1887
- def do_npm_install(self, package_json_folder: str, force: bool, verbosity: int) -> None:
1939
+ def do_npm_install(self, package_json_folder: str, force: bool, verbosity: int = 1) -> None:
1888
1940
  argument1 = "install"
1889
1941
  if force:
1890
1942
  argument1 = f"{argument1} --force"
@@ -2092,6 +2144,14 @@ class TasksForCommonProjectStructure:
2092
2144
  GeneralUtilities.ensure_directory_does_not_exist(target_folder)
2093
2145
  shutil.copytree(source_folder, target_folder)
2094
2146
 
2147
+ @GeneralUtilities.check_arguments
2148
+ def copy_resources_from_global_project_resources(self, codeunit_folder: str, resource_name: str) -> None:
2149
+ self.assert_is_codeunit_folder(codeunit_folder)
2150
+ source_folder: str = GeneralUtilities.resolve_relative_path(f"../Other/Resources/{resource_name}", codeunit_folder)
2151
+ target_folder: str = GeneralUtilities.resolve_relative_path(f"Other/Resources/{resource_name}", codeunit_folder)
2152
+ GeneralUtilities.ensure_directory_does_not_exist(target_folder)
2153
+ shutil.copytree(source_folder, target_folder)
2154
+
2095
2155
  @GeneralUtilities.check_arguments
2096
2156
  def generate_openapi_file(self, buildscript_file: str, runtime: str, verbosity: int, commandline_arguments: list[str], swagger_document_name: str = "APISpecification") -> None:
2097
2157
  GeneralUtilities.write_message_to_stdout("Generate OpenAPI-specification-file...")
@@ -2354,16 +2414,18 @@ class TasksForCommonProjectStructure:
2354
2414
  self.__sc.update_dependencies_of_dotnet_project(csproj_file, verbosity, ignored_dependencies)
2355
2415
 
2356
2416
  @GeneralUtilities.check_arguments
2357
- def update_dependencies_of_typical_node_codeunit(self, update_script_file: str, verbosity: int, cmd_args: list[str]) -> None:
2358
- codeunit_folder = GeneralUtilities.resolve_relative_path("..", os.path.dirname(update_script_file))
2359
- ignored_dependencies = self.get_dependencies_which_are_ignored_from_updates(codeunit_folder, True)
2417
+ def update_dependencies_of_package_json(self, folder: str, verbosity: int, cmd_args: list[str]) -> None:
2418
+ if self.is_codeunit_folder(folder):
2419
+ ignored_dependencies = self.get_dependencies_which_are_ignored_from_updates(folder, True)
2420
+ else:
2421
+ ignored_dependencies = []
2360
2422
  # TODO consider ignored_dependencies
2361
- result = self.run_with_epew("npm", "outdated", codeunit_folder, verbosity, throw_exception_if_exitcode_is_not_zero=False)
2423
+ result = self.run_with_epew("npm", "outdated", folder, verbosity, throw_exception_if_exitcode_is_not_zero=False)
2362
2424
  if result[0] == 0:
2363
2425
  return # all dependencies up to date
2364
2426
  elif result[0] == 1:
2365
2427
  package_json_content = None
2366
- package_json_file = f"{codeunit_folder}/package.json"
2428
+ package_json_file = f"{folder}/package.json"
2367
2429
  with open(package_json_file, "r", encoding="utf-8") as package_json_file_object:
2368
2430
  package_json_content = json.load(package_json_file_object)
2369
2431
  lines = GeneralUtilities.string_to_lines(result[1])[1:][:-1]
@@ -2377,7 +2439,7 @@ class TasksForCommonProjectStructure:
2377
2439
  package_json_content["devDependencies"][package] = latest_version
2378
2440
  with open(package_json_file, "w", encoding="utf-8") as package_json_file_object:
2379
2441
  json.dump(package_json_content, package_json_file_object, indent=4)
2380
- self.do_npm_install(codeunit_folder, True, verbosity)
2442
+ self.do_npm_install(folder, True, verbosity)
2381
2443
  else:
2382
2444
  GeneralUtilities.write_message_to_stderr("Update dependencies resulted in an error.")
2383
2445
 
@@ -3416,7 +3478,7 @@ class TasksForCommonProjectStructure:
3416
3478
  self.__sc.install_requirementstxt_file(repository_folde+"/Other/requirements.txt", verbosity)
3417
3479
 
3418
3480
  @GeneralUtilities.check_arguments
3419
- def update_submodule(self, repository_folder: str, submodule_name: str,local_branch:str="main",remote_branch:str="main",remote:str="origin"):
3481
+ def update_submodule(self, repository_folder: str, submodule_name: str, local_branch: str = "main", remote_branch: str = "main", remote: str = "origin"):
3420
3482
  submodule_folder = GeneralUtilities.resolve_relative_path("Other/Resources/Submodules/"+submodule_name, repository_folder)
3421
3483
  self.__sc.git_fetch(submodule_folder, remote)
3422
3484
  self.__sc.git_checkout(submodule_folder, local_branch)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 3.5.149
3
+ Version: 3.5.151
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
@@ -34,7 +34,7 @@ Requires-Dist: Pillow>=11.3.0
34
34
  Requires-Dist: psutil>=7.0.0
35
35
  Requires-Dist: pycdlib>=1.14.0
36
36
  Requires-Dist: Pygments>=2.19.2
37
- Requires-Dist: pylint>=3.3.7
37
+ Requires-Dist: pylint>=3.3.8
38
38
  Requires-Dist: pyOpenSSL>=25.1.0
39
39
  Requires-Dist: PyPDF>=5.9.0
40
40
  Requires-Dist: pytest>=8.4.1
@@ -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=GJ44S6VaBVwX5Dd6MIrdZn6I0dpaaYKVq9w-N0nMXlo,4496
10
- ScriptCollection/ScriptCollectionCore.py,sha256=2GF7AUB6QN2o3N3-KPhdHGzxwpZryfWQIPRGLUMRmRo,138093
11
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=GoIVDPIGua2ZJIGM4zeJL1nNLwh7X1W8BI-2z-ESgb0,241302
10
+ ScriptCollection/ScriptCollectionCore.py,sha256=YJ6uOGQa224jtsva_OX3r8h2aIzGR9GAfJH4h-9iIAc,138093
11
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=9vccEWsxlW7xGXFLc2RPPFMWCkmoGxbSGu7hi9NxkeU,244959
12
12
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- scriptcollection-3.5.149.dist-info/METADATA,sha256=Xt22-tDxFlz_5bbY-hDalMAXE7ndoPYu7QeEGLC822g,7689
14
- scriptcollection-3.5.149.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- scriptcollection-3.5.149.dist-info/entry_points.txt,sha256=UyXXDpgVK6U0rkdbe2g-d3a7JFhLFWTUFSYWhcJE7IA,4214
16
- scriptcollection-3.5.149.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
- scriptcollection-3.5.149.dist-info/RECORD,,
13
+ scriptcollection-3.5.151.dist-info/METADATA,sha256=-EuHJHBjH-Oe9njZujrMzqr5aUXDVt_20DyCPY_81RE,7689
14
+ scriptcollection-3.5.151.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ scriptcollection-3.5.151.dist-info/entry_points.txt,sha256=AvmVO9iyWImExpvzL3YYQ9AOEiUIN9guPRRG_W_VNWY,4116
16
+ scriptcollection-3.5.151.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
17
+ scriptcollection-3.5.151.dist-info/RECORD,,
@@ -28,7 +28,6 @@ scgeneratecertificate = ScriptCollection.Executables:GenerateCertificate
28
28
  scgeneratecertificateauthority = ScriptCollection.Executables:GenerateCertificateAuthority
29
29
  scgeneratecertificatesignrequest = ScriptCollection.Executables:GenerateCertificateSignRequest
30
30
  scgeneratesnkfiles = ScriptCollection.Executables:GenerateSnkFiles
31
- scgeneratetasksfilefromworkspacefile = ScriptCollection.Executables:GenerateTaskfileFromWorkspacefile
32
31
  scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
33
32
  schealthcheck = ScriptCollection.Executables:Healthcheck
34
33
  sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
@@ -51,7 +50,7 @@ scremovefolder = ScriptCollection.Executables:RemoveFolder
51
50
  screname = ScriptCollection.Executables:Rename
52
51
  screplacesubstringsinfilenames = ScriptCollection.Executables:ReplaceSubstringsInFilenames
53
52
  scsearchinfiles = ScriptCollection.Executables:SearchInFiles
54
- scsetfilecontent = ScriptCollection.Executables:SetFileContent
53
+ scsetcontentoffile = ScriptCollection.Executables:SetContentOfFile
55
54
  scshow2faasqrcode = ScriptCollection.Executables:Show2FAAsQRCode
56
55
  scshowmissingfiles = ScriptCollection.Executables:ShowMissingFiles
57
56
  scsigncertificate = ScriptCollection.Executables:SignCertificate