ScriptCollection 3.5.59__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.
- ScriptCollection/Executables.py +98 -12
- ScriptCollection/ScriptCollectionCore.py +2 -2
- ScriptCollection/TasksForCommonProjectStructure.py +9 -5
- {ScriptCollection-3.5.59.dist-info → ScriptCollection-3.5.61.dist-info}/METADATA +2 -2
- {ScriptCollection-3.5.59.dist-info → ScriptCollection-3.5.61.dist-info}/RECORD +8 -8
- {ScriptCollection-3.5.59.dist-info → ScriptCollection-3.5.61.dist-info}/entry_points.txt +5 -0
- {ScriptCollection-3.5.59.dist-info → ScriptCollection-3.5.61.dist-info}/WHEEL +0 -0
- {ScriptCollection-3.5.59.dist-info → ScriptCollection-3.5.61.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
|
@@ -416,9 +416,18 @@ def SetContentOfFile() -> int:
|
|
|
416
416
|
|
|
417
417
|
|
|
418
418
|
def PrintFileContent() -> int:
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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.
|
|
34
|
+
version = "3.5.61"
|
|
35
35
|
__version__ = version
|
|
36
36
|
|
|
37
37
|
|
|
@@ -1397,7 +1397,7 @@ class ScriptCollectionCore:
|
|
|
1397
1397
|
if err_line.endswith("\n"):
|
|
1398
1398
|
err_line = err_line[:-1]
|
|
1399
1399
|
if print_live_output:
|
|
1400
|
-
print(err_line, end='\n', file=sys.stderr, flush=True)
|
|
1400
|
+
print(err_line, end='\n', file=sys.stdout if print_errors_as_information else sys.stderr, flush=True)
|
|
1401
1401
|
if 0 < len(stderr):
|
|
1402
1402
|
stderr = stderr+"\n"
|
|
1403
1403
|
stderr = stderr+err_line
|
|
@@ -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 = "
|
|
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()
|
|
@@ -2224,16 +2229,15 @@ class TasksForCommonProjectStructure:
|
|
|
2224
2229
|
|
|
2225
2230
|
@GeneralUtilities.check_arguments
|
|
2226
2231
|
def update_dependencies_of_typical_node_codeunit(self, update_script_file: str, verbosity: int, cmd_args: list[str]) -> None:
|
|
2227
|
-
current_folder = os.path.dirname(update_script_file)
|
|
2228
2232
|
codeunit_folder = GeneralUtilities.resolve_relative_path("..", os.path.dirname(update_script_file))
|
|
2229
2233
|
ignored_dependencies = self.get_dependencies_which_are_ignored_from_updates(codeunit_folder, True)
|
|
2230
2234
|
# TODO consider ignored_dependencies
|
|
2231
|
-
result = self.run_with_epew("npm", "outdated",
|
|
2235
|
+
result = self.run_with_epew("npm", "outdated", codeunit_folder, verbosity, throw_exception_if_exitcode_is_not_zero=False)
|
|
2232
2236
|
if result[0] == 0:
|
|
2233
2237
|
return # all dependencies up to date
|
|
2234
2238
|
elif result[0] == 1:
|
|
2235
2239
|
package_json_content = None
|
|
2236
|
-
package_json_file = f"{
|
|
2240
|
+
package_json_file = f"{codeunit_folder}/package.json"
|
|
2237
2241
|
with open(package_json_file, "r", encoding="utf-8") as package_json_file_object:
|
|
2238
2242
|
package_json_content = json.load(package_json_file_object)
|
|
2239
2243
|
lines = GeneralUtilities.string_to_lines(result[1])[1:][:-1]
|
|
@@ -2247,7 +2251,7 @@ class TasksForCommonProjectStructure:
|
|
|
2247
2251
|
package_json_content["devDependencies"][package] = latest_version
|
|
2248
2252
|
with open(package_json_file, "w", encoding="utf-8") as package_json_file_object:
|
|
2249
2253
|
json.dump(package_json_content, package_json_file_object, indent=4)
|
|
2250
|
-
self.
|
|
2254
|
+
self.do_npm_install(codeunit_folder, True, verbosity)
|
|
2251
2255
|
else:
|
|
2252
2256
|
GeneralUtilities.write_message_to_stderr("Update dependencies resulted in an error.")
|
|
2253
2257
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ScriptCollection
|
|
3
|
-
Version: 3.5.
|
|
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
|
|
@@ -23,7 +23,7 @@ Classifier: Topic :: Utilities
|
|
|
23
23
|
Requires-Python: >=3.10
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
Requires-Dist: build>=1.2.2.post1
|
|
26
|
-
Requires-Dist: coverage>=7.6.
|
|
26
|
+
Requires-Dist: coverage>=7.6.11
|
|
27
27
|
Requires-Dist: cyclonedx-bom>=5.1.2
|
|
28
28
|
Requires-Dist: defusedxml>=0.7.1
|
|
29
29
|
Requires-Dist: keyboard>=0.13.5
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
ScriptCollection/Executables.py,sha256=
|
|
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=
|
|
9
|
-
ScriptCollection/TasksForCommonProjectStructure.py,sha256=
|
|
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.
|
|
13
|
-
ScriptCollection-3.5.
|
|
14
|
-
ScriptCollection-3.5.
|
|
15
|
-
ScriptCollection-3.5.
|
|
16
|
-
ScriptCollection-3.5.
|
|
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
|
|
File without changes
|
|
File without changes
|