ScriptCollection 3.5.60__py3-none-any.whl → 3.5.61__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.
@@ -416,9 +416,18 @@ def SetContentOfFile() -> int:
416
416
 
417
417
 
418
418
  def PrintFileContent() -> int:
419
- GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
420
- # TODO implement function
421
- return 1
419
+ parser = argparse.ArgumentParser(description="This function prints the size of a file")
420
+ parser.add_argument('-p', '--path', required=True)
421
+ parser.add_argument('-e', '--encoding', required=False, default="utf-8")
422
+ args = parser.parse_args()
423
+ file = args.path
424
+ encoding = args.encoding
425
+ if os.path.isfile(file):
426
+ GeneralUtilities.write_message_to_stdout(GeneralUtilities.read_text_from_file(file, encoding))
427
+ return 0
428
+ else:
429
+ GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
430
+ return 1
422
431
 
423
432
 
424
433
  def CreateFile() -> int:
@@ -458,9 +467,17 @@ def RegexReplaceInFile() -> int:
458
467
 
459
468
 
460
469
  def PrintFileSize() -> int:
461
- GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
462
- # TODO implement function
463
- return 1
470
+ parser = argparse.ArgumentParser(description="This function prints the size of a file")
471
+ parser.add_argument('-p', '--path', required=True)
472
+ args = parser.parse_args()
473
+ file = args.path
474
+ if os.path.isfile(file):
475
+ size = os.path.getsize(file)
476
+ GeneralUtilities.write_message_to_stdout(str(size))
477
+ return 0
478
+ else:
479
+ GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
480
+ return 1
464
481
 
465
482
 
466
483
  def FileContainsContent() -> int:
@@ -471,15 +488,35 @@ def FileContainsContent() -> int:
471
488
 
472
489
 
473
490
  def RemoveFile() -> int:
474
- GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
475
- # TODO implement function
476
- return 1
491
+ parser = argparse.ArgumentParser(description="This function removes a file.")
492
+ parser.add_argument('-p', '--path', required=True)
493
+ parser.add_argument('-e', '--errorwhennotexists', action='store_true', required=False, default=False)
494
+ args = parser.parse_args()
495
+ file = args.path
496
+ errorwhennotexists = args.errorwhennotexists
497
+ if os.path.isfile(file):
498
+ GeneralUtilities.ensure_file_does_not_exist(file)
499
+ else:
500
+ if errorwhennotexists:
501
+ GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
502
+ return 1
503
+ return 0
477
504
 
478
505
 
479
506
  def RemoveFolder() -> int:
480
- GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
481
- # TODO implement function
482
- return 1
507
+ parser = argparse.ArgumentParser(description="This function removes a folder.")
508
+ parser.add_argument('-p', '--path', required=True)
509
+ parser.add_argument('-e', '--errorwhennotexists', action='store_true', required=False, default=False)
510
+ args = parser.parse_args()
511
+ folder = args.path
512
+ errorwhennotexists = args.errorwhennotexists
513
+ if os.path.isdir(folder):
514
+ GeneralUtilities.ensure_directory_does_not_exist(folder)
515
+ else:
516
+ if errorwhennotexists:
517
+ GeneralUtilities.write_exception_to_stderr(f"Folder '{folder}' does not exist.")
518
+ return 1
519
+ return 0
483
520
 
484
521
 
485
522
  def Rename() -> int:
@@ -489,3 +526,52 @@ def Rename() -> int:
489
526
  args = parser.parse_args()
490
527
  os.rename(args.source, args.target)
491
528
  return 0
529
+
530
+
531
+ def PrintOSName() -> int:
532
+ GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
533
+ if GeneralUtilities.current_system_is_windows():
534
+ GeneralUtilities.write_message_to_stdout("Windows")
535
+ elif GeneralUtilities.current_system_is_linux():
536
+ GeneralUtilities.write_message_to_stdout("Linux")
537
+ # TODO also consider Mac, Unix, etc.
538
+ else:
539
+ GeneralUtilities.write_message_to_stderr("Unknown OS.")
540
+ return 1
541
+ return 0
542
+
543
+
544
+ def PrintCurrecntWorkingDirectory() -> int:
545
+ GeneralUtilities.write_message_to_stdout(os.getcwd())
546
+ return 0
547
+
548
+
549
+ def ListFolderContent() -> int:
550
+ 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
+ return 1
557
+
558
+
559
+ def ForEach() -> int:
560
+ GeneralUtilities.write_exception_to_stderr("This function is not implemented yet.")
561
+ # TODO implement function
562
+ return 1
563
+
564
+
565
+ def NpmI() -> int:
566
+ parser = argparse.ArgumentParser(description="Does \"npm clean install\".")
567
+ parser.add_argument('-d', '--directory', required=False, default=".")
568
+ parser.add_argument('-f', '--force', action='store_true', required=False, default=False)
569
+ parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False)
570
+ args = parser.parse_args()
571
+ if os.path.isabs(args.directory):
572
+ folder = args.directory
573
+ else:
574
+ folder = GeneralUtilities.resolve_relative_path(args.directory, os.getcwd())
575
+ t = TasksForCommonProjectStructure()
576
+ t.do_npm_install(folder, args.force, 3 if args.verbose else 0)
577
+ return 0
@@ -31,7 +31,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
31
31
  from .ProgramRunnerPopen import ProgramRunnerPopen
32
32
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
33
33
 
34
- version = "3.5.60"
34
+ version = "3.5.61"
35
35
  __version__ = version
36
36
 
37
37
 
@@ -1811,11 +1811,16 @@ class TasksForCommonProjectStructure:
1811
1811
  argument1 = f"{argument1} --force"
1812
1812
  self.run_with_epew("npm", argument1, package_json_folder, verbosity=verbosity)
1813
1813
 
1814
- argument2 = "clean-install"
1814
+ argument2 = "install --package-lock-only"
1815
1815
  if force:
1816
1816
  argument2 = f"{argument2} --force"
1817
1817
  self.run_with_epew("npm", argument2, package_json_folder, verbosity=verbosity)
1818
1818
 
1819
+ argument3 = "clean-install"
1820
+ if force:
1821
+ argument3 = f"{argument3} --force"
1822
+ self.run_with_epew("npm", argument3, package_json_folder, verbosity=verbosity)
1823
+
1819
1824
  @GeneralUtilities.check_arguments
1820
1825
  def run_with_epew(self, program: str, argument: str = "", working_directory: str = None, verbosity: int = 1, print_errors_as_information: bool = False, log_file: str = None, timeoutInSeconds: int = 600, addLogOverhead: bool = False, title: str = None, log_namespace: str = "", arguments_for_log: list[str] = None, throw_exception_if_exitcode_is_not_zero: bool = True, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
1821
1826
  sc: ScriptCollectionCore = ScriptCollectionCore()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ScriptCollection
3
- Version: 3.5.60
3
+ Version: 3.5.61
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=j79qOgjHKgha2EW1uMfKf1Woa6rsChL0yqJgIA-YkYU,24586
1
+ ScriptCollection/Executables.py,sha256=kON_jatJe84iCJj60uUjA-Aj0ytERRe0FUDWbOWUe6s,28089
2
2
  ScriptCollection/GeneralUtilities.py,sha256=nlSZSsQVHWxf0Yzz4PjgZm39rgvIltVof8gL2YPgR7s,38805
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=th3pd2sKt6kBJQ1-7WrjnYOVmbWPfDrYzRkVzmmu6C4,111227
9
- ScriptCollection/TasksForCommonProjectStructure.py,sha256=IOrvyAgnA2PmXbotfxdXhwIwdciFiXvtPm2URcpDSVc,212887
8
+ ScriptCollection/ScriptCollectionCore.py,sha256=gmFAw9p9gVi4Z4vCtAsCS7bQUDLVMHJ66AEtuoaLx1o,111227
9
+ ScriptCollection/TasksForCommonProjectStructure.py,sha256=B3-KSAZOR_UKSeLsdAxyZu2ylsRSjDvlj0272TXSEfA,213090
10
10
  ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
11
11
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- ScriptCollection-3.5.60.dist-info/METADATA,sha256=SwD2qxvbM1YxPLHJGuKrRLXgCDhJ3pcgJDcih0bPGTc,7664
13
- ScriptCollection-3.5.60.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- ScriptCollection-3.5.60.dist-info/entry_points.txt,sha256=AQz2mMJ787Aw5Q_ItC6Q-Mo_DGYlM_OPEkovrgsrRF0,3192
15
- ScriptCollection-3.5.60.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
- ScriptCollection-3.5.60.dist-info/RECORD,,
12
+ ScriptCollection-3.5.61.dist-info/METADATA,sha256=lrV7TcbmII8Mz2Bd7CFXv46tw-XIr8YozP5sfDCOgbk,7664
13
+ ScriptCollection-3.5.61.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ ScriptCollection-3.5.61.dist-info/entry_points.txt,sha256=wspYVXWH8kon-wRQTAFEO11JoLJ0fEnOIG7tE7R-xtQ,3502
15
+ ScriptCollection-3.5.61.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
+ ScriptCollection-3.5.61.dist-info/RECORD,,
@@ -18,6 +18,7 @@ scfilecontainscontent = ScriptCollection.Executables:FileContainsContent
18
18
  scfileexists = ScriptCollection.Executables:FileExists
19
19
  scfilenameobfuscator = ScriptCollection.Executables:FilenameObfuscator
20
20
  scfolderexists = ScriptCollection.Executables:FolderExists
21
+ scforeach = ScriptCollection.Executables:ForEach
21
22
  scgeneratearc42referencetemplate = ScriptCollection.Executables:GenerateARC42ReferenceTemplate
22
23
  scgeneratecertificate = ScriptCollection.Executables:GenerateCertificate
23
24
  scgeneratecertificateauthority = ScriptCollection.Executables:GenerateCertificateAuthority
@@ -26,12 +27,16 @@ scgeneratesnkfiles = ScriptCollection.Executables:GenerateSnkFiles
26
27
  scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
27
28
  schealthcheck = ScriptCollection.Executables:Healthcheck
28
29
  sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
30
+ sclistfoldercontent = ScriptCollection.Executables:ListFolderContent
29
31
  scmergepdfs = ScriptCollection.Executables:MergePDFs
32
+ scnpmi = ScriptCollection.Executables:NpmI
30
33
  scobfuscatefilesfolder = ScriptCollection.Executables:ObfuscateFilesFolder
31
34
  scorganizelinesinfile = ScriptCollection.Executables:OrganizeLinesInFile
32
35
  scpdftoimage = ScriptCollection.Executables:PDFToImage
36
+ scprintcurrentworkingdirectory = ScriptCollection.Executables:PrintCurrecntWorkingDirectory
33
37
  scprintfilecontent = ScriptCollection.Executables:PrintFileContent
34
38
  scprintfilesize = ScriptCollection.Executables:PrintFileSize
39
+ scprintosname = ScriptCollection.Executables:PrintOSName
35
40
  scregexreplaceinfile = ScriptCollection.Executables:RegexReplaceInFile
36
41
  scremoveFolder = ScriptCollection.Executables:RemoveFolder
37
42
  scremovefile = ScriptCollection.Executables:RemoveFile