ScriptCollection 3.5.67__py3-none-any.whl → 3.5.68__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.
@@ -3,6 +3,7 @@ import argparse
3
3
  import time
4
4
  import traceback
5
5
  import sys
6
+ import shutil
6
7
  import keyboard
7
8
  from .TasksForCommonProjectStructure import TasksForCommonProjectStructure
8
9
  from .ScriptCollectionCore import ScriptCollectionCore
@@ -528,13 +529,30 @@ def Rename() -> int:
528
529
  return 0
529
530
 
530
531
 
532
+ def Copy() -> int:
533
+ parser = argparse.ArgumentParser(description="This function copies a file or folder.")
534
+ parser.add_argument('-s', '--source', required=True)
535
+ parser.add_argument('-t', '--target', required=True)
536
+ args = parser.parse_args()
537
+ if os.path.isfile(args.target) or os.path.isdir(args.target):
538
+ raise ValueError(f"Can not copy to '{args.target}' because the target already exists.")
539
+ if os.path.isfile(args.source):
540
+ shutil.copyfile(args.source, args.target)
541
+ elif os.path.isdir(args.source):
542
+ GeneralUtilities.ensure_directory_exists(args.target)
543
+ GeneralUtilities.copy_content_of_folder(args.source,args.target)
544
+ else:
545
+ raise ValueError(f"'{args.source}' can not be copied because the path does not exist.")
546
+ return 0
547
+
548
+
531
549
  def PrintOSName() -> int:
532
550
  GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
533
551
  if GeneralUtilities.current_system_is_windows():
534
552
  GeneralUtilities.write_message_to_stdout("Windows")
535
553
  elif GeneralUtilities.current_system_is_linux():
536
554
  GeneralUtilities.write_message_to_stdout("Linux")
537
- # TODO also consider Mac, Unix, etc.
555
+ # TODO consider Mac, Unix, etc. too
538
556
  else:
539
557
  GeneralUtilities.write_message_to_stderr("Unknown OS.")
540
558
  return 1
@@ -548,19 +566,29 @@ def PrintCurrecntWorkingDirectory() -> int:
548
566
 
549
567
  def ListFolderContent() -> int:
550
568
  GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
551
- # TODO implement function
552
- # TODO add option to include/exclude full path
553
- # TODO add option to also list transitively list subfolder
554
- # TODO add option to print only folder
555
- # TODO add option to print only files
556
569
  parser = argparse.ArgumentParser(description="This function lists folder-content.")
557
570
  parser.add_argument('-p', '--path', required=True)
571
+ parser.add_argument('-f', '--excludefiles', action='store_true', required=False,default=False)
572
+ parser.add_argument('-d', '--excludedirectories', action='store_true', required=False,default=False)
573
+ parser.add_argument('-n', '--printonlynamewithoutpath', action='store_true', required=False,default=False)
574
+ # TODO add option to also list transitively list subfolder
575
+ # TODO add option to show only content which matches a filter by extension or regex or glob-pattern
558
576
  args=parser.parse_args()
559
577
  folder=args.path
560
578
  if not os.path.isabs(folder):
561
579
  folder=GeneralUtilities.resolve_relative_path(folder,os.getcwd())
562
- for file in GeneralUtilities.get_direct_files_of_folder(folder):
563
- GeneralUtilities.write_message_to_stdout(file)
580
+ content=[]
581
+ if not args.excludefiles:
582
+ content=content+GeneralUtilities.get_direct_files_of_folder(folder)
583
+ if not args.excludedirectories:
584
+ content=content+GeneralUtilities.get_direct_folders_of_folder(folder)
585
+ for contentitem in content:
586
+ content_to_print:str=None
587
+ if args.printonlynamewithoutpath:
588
+ content_to_print=os.path.basename(contentitem)
589
+ else:
590
+ content_to_print= contentitem
591
+ GeneralUtilities.write_message_to_stdout(content_to_print)
564
592
  return 0
565
593
 
566
594
 
@@ -32,7 +32,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
32
32
  from .ProgramRunnerPopen import ProgramRunnerPopen
33
33
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
34
34
 
35
- version = "3.5.67"
35
+ version = "3.5.68"
36
36
  __version__ = version
37
37
 
38
38
 
@@ -619,11 +619,21 @@ class ScriptCollectionCore:
619
619
  os.rename(renamed_item, original_name)
620
620
 
621
621
  @GeneralUtilities.check_arguments
622
- def list_files(self, path: str) -> list[str]:
622
+ def list_content(self, path: str,include_files:bool,include_folder:bool) -> list[str]:
623
623
  if self.program_runner.will_be_executed_locally():
624
- return GeneralUtilities.get_direct_files_of_folder(path)
624
+ result=[]
625
+ if include_files:
626
+ result=result + GeneralUtilities.get_direct_files_of_folder(path)
627
+ if include_folder:
628
+ result=result + GeneralUtilities.get_direct_folders_of_folder(path)
629
+ return result
625
630
  else:
626
- exit_code, stdout, stderr, _ = self.run_program_argsasarray("scfileexists", ["--path", path])
631
+ arguments=["--path", path]
632
+ if not include_files:
633
+ arguments=arguments+["--excludefiles"]
634
+ if not include_folder:
635
+ arguments=arguments+["--excludedirectories"]
636
+ exit_code, stdout, stderr, _ = self.run_program_argsasarray("sclistfoldercontent", arguments)
627
637
  if exit_code == 0:
628
638
  result:list[str]=[]
629
639
  for line in stdout.split("\n"):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ScriptCollection
3
- Version: 3.5.67
3
+ Version: 3.5.68
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
@@ -1,16 +1,16 @@
1
- ScriptCollection/Executables.py,sha256=jGJIVEjRuOEpcC6ZvCny22DgHZPtr4pmKZj6b-Zn-fA,28514
1
+ ScriptCollection/Executables.py,sha256=dyToDh4vd0k0Ox9TE4E_4-jY46XU6A6rguOL5R6Moj4,29977
2
2
  ScriptCollection/GeneralUtilities.py,sha256=WSBawT958x_0H-hnPg3S3DGzP3KOQTADtZtP145I-M4,39473
3
3
  ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
4
4
  ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
5
5
  ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
6
6
  ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
7
7
  ScriptCollection/RPStream.py,sha256=NRRHL3YSP3D9MuAV2jB_--0KUKCsvJGxeKnxgrRZ9kY,1545
8
- ScriptCollection/ScriptCollectionCore.py,sha256=Gjr-4UES3iYDUuYoBTN8XIaLbuzTq4FyMD_6cuOseAY,113595
8
+ ScriptCollection/ScriptCollectionCore.py,sha256=Zbc-oWrgLEqz6dB2M0EJORG_9eU1byGaziHI2iFZUSo,114066
9
9
  ScriptCollection/TasksForCommonProjectStructure.py,sha256=F6e045gUvSxpOcHk61OVnlod_Zn9JSNXrv6I2SzWoVc,214997
10
10
  ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
11
11
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- ScriptCollection-3.5.67.dist-info/METADATA,sha256=jSXXQC_Q1zoKYsvPm38722Tok5dvc3a7dtulFS9j9Uk,7664
13
- ScriptCollection-3.5.67.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- ScriptCollection-3.5.67.dist-info/entry_points.txt,sha256=wspYVXWH8kon-wRQTAFEO11JoLJ0fEnOIG7tE7R-xtQ,3502
15
- ScriptCollection-3.5.67.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
- ScriptCollection-3.5.67.dist-info/RECORD,,
12
+ ScriptCollection-3.5.68.dist-info/METADATA,sha256=z55DUNqZEXZqXwh3pBsCcb5Ha8fy_XXkZa9SwB2tsh0,7664
13
+ ScriptCollection-3.5.68.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ ScriptCollection-3.5.68.dist-info/entry_points.txt,sha256=psYFu5te0W8zF5k444Qi21IZN4UwwGbw-XR22nvKTYE,3545
15
+ ScriptCollection-3.5.68.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
+ ScriptCollection-3.5.68.dist-info/RECORD,,
@@ -6,6 +6,7 @@ scbuildcodeunitsc = ScriptCollection.Executables:BuildCodeUnitsC
6
6
  sccalculatebitcoinblockhash = ScriptCollection.Executables:CalculateBitcoinBlockHash
7
7
  scchangefileextension = ScriptCollection.Executables:ChangeFileExtensions
8
8
  scchangehashofprogram = ScriptCollection.Executables:ChangeHashOfProgram
9
+ sccopy = ScriptCollection.Executables:Copy
9
10
  sccreatechangelogentry = ScriptCollection.Executables:CreateChangelogEntry
10
11
  sccreateemptyfilewithspecificsize = ScriptCollection.Executables:CreateEmptyFileWithSpecificSize
11
12
  sccreatefile = ScriptCollection.Executables:CreateFile