ScriptCollection 3.5.83__py3-none-any.whl → 3.5.84__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.
@@ -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.83"
35
+ version = "3.5.84"
36
36
  __version__ = version
37
37
 
38
38
 
@@ -273,14 +273,17 @@ class ScriptCollectionCore:
273
273
 
274
274
  @GeneralUtilities.check_arguments
275
275
  def git_fetch(self, folder: str, remotename: str = "--all") -> None:
276
+ self.assert_is_git_repository(folder)
276
277
  self.run_program_argsasarray("git", ["fetch", remotename, "--tags", "--prune"], folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
277
278
 
278
279
  @GeneralUtilities.check_arguments
279
280
  def git_fetch_in_bare_repository(self, folder: str, remotename, localbranch: str, remotebranch: str) -> None:
281
+ self.assert_is_git_repository(folder)
280
282
  self.run_program_argsasarray("git", ["fetch", remotename, f"{remotebranch}:{localbranch}"], folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
281
283
 
282
284
  @GeneralUtilities.check_arguments
283
285
  def git_remove_branch(self, folder: str, branchname: str) -> None:
286
+ self.assert_is_git_repository(folder)
284
287
  self.run_program("git", f"branch -D {branchname}", folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
285
288
 
286
289
  @GeneralUtilities.check_arguments
@@ -289,6 +292,7 @@ class ScriptCollectionCore:
289
292
 
290
293
  @GeneralUtilities.check_arguments
291
294
  def git_push(self, folder: str, remotename: str, localbranchname: str, remotebranchname: str, forcepush: bool = False, pushalltags: bool = True, verbosity: int = 0) -> None:
295
+ self.assert_is_git_repository(folder)
292
296
  argument = ["push", "--recurse-submodules=on-demand", remotename, f"{localbranchname}:{remotebranchname}"]
293
297
  if (forcepush):
294
298
  argument.append("--force")
@@ -303,6 +307,7 @@ class ScriptCollectionCore:
303
307
 
304
308
  @GeneralUtilities.check_arguments
305
309
  def git_pull(self, folder: str, remote: str, localbranchname: str, remotebranchname: str, force: bool = False) -> None:
310
+ self.assert_is_git_repository(folder)
306
311
  argument = f"pull {remote} {remotebranchname}:{localbranchname}"
307
312
  if force:
308
313
  argument = f"{argument} --force"
@@ -310,6 +315,7 @@ class ScriptCollectionCore:
310
315
 
311
316
  @GeneralUtilities.check_arguments
312
317
  def git_list_remote_branches(self, folder: str, remote: str, fetch: bool) -> list[str]:
318
+ self.assert_is_git_repository(folder)
313
319
  if fetch:
314
320
  self.git_fetch(folder, remote)
315
321
  run_program_result = self.run_program("git", f"branch -rl {remote}/*", folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
@@ -343,20 +349,24 @@ class ScriptCollectionCore:
343
349
 
344
350
  @GeneralUtilities.check_arguments
345
351
  def git_get_all_remote_names(self, directory: str) -> list[str]:
352
+ self.assert_is_git_repository(directory)
346
353
  result = GeneralUtilities.string_to_lines(self.run_program_argsasarray("git", ["remote"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)[1], False)
347
354
  return result
348
355
 
349
356
  @GeneralUtilities.check_arguments
350
357
  def git_get_remote_url(self, directory: str, remote_name: str) -> str:
358
+ self.assert_is_git_repository(directory)
351
359
  result = GeneralUtilities.string_to_lines(self.run_program_argsasarray("git", ["remote", "get-url", remote_name], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)[1], False)
352
360
  return result[0].replace('\n', '')
353
361
 
354
362
  @GeneralUtilities.check_arguments
355
363
  def repository_has_remote_with_specific_name(self, directory: str, remote_name: str) -> bool:
364
+ self.assert_is_git_repository(directory)
356
365
  return remote_name in self.git_get_all_remote_names(directory)
357
366
 
358
367
  @GeneralUtilities.check_arguments
359
368
  def git_add_or_set_remote_address(self, directory: str, remote_name: str, remote_address: str) -> None:
369
+ self.assert_is_git_repository(directory)
360
370
  if (self.repository_has_remote_with_specific_name(directory, remote_name)):
361
371
  self.run_program_argsasarray("git", ['remote', 'set-url', 'remote_name', remote_address], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
362
372
  else:
@@ -364,34 +374,43 @@ class ScriptCollectionCore:
364
374
 
365
375
  @GeneralUtilities.check_arguments
366
376
  def git_stage_all_changes(self, directory: str) -> None:
377
+ self.assert_is_git_repository(directory)
367
378
  self.run_program_argsasarray("git", ["add", "-A"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
368
379
 
369
380
  @GeneralUtilities.check_arguments
370
381
  def git_unstage_all_changes(self, directory: str) -> None:
382
+ self.assert_is_git_repository(directory)
371
383
  self.run_program_argsasarray("git", ["reset"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
384
+ #TODO check if this will also be done for submodules
372
385
 
373
386
  @GeneralUtilities.check_arguments
374
387
  def git_stage_file(self, directory: str, file: str) -> None:
388
+ self.assert_is_git_repository(directory)
375
389
  self.run_program_argsasarray("git", ['stage', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
376
390
 
377
391
  @GeneralUtilities.check_arguments
378
392
  def git_unstage_file(self, directory: str, file: str) -> None:
393
+ self.assert_is_git_repository(directory)
379
394
  self.run_program_argsasarray("git", ['reset', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
380
395
 
381
396
  @GeneralUtilities.check_arguments
382
397
  def git_discard_unstaged_changes_of_file(self, directory: str, file: str) -> None:
383
398
  """Caution: This method works really only for 'changed' files yet. So this method does not work properly for new or renamed files."""
399
+ self.assert_is_git_repository(directory)
384
400
  self.run_program_argsasarray("git", ['checkout', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
385
401
 
386
402
  @GeneralUtilities.check_arguments
387
403
  def git_discard_all_unstaged_changes(self, directory: str) -> None:
388
404
  """Caution: This function executes 'git clean -df'. This can delete files which maybe should not be deleted. Be aware of that."""
405
+ self.assert_is_git_repository(directory)
389
406
  self.run_program_argsasarray("git", ['clean', '-df'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
390
407
  self.run_program_argsasarray("git", ['checkout', '.'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
408
+ #TODO check if this will also be done for submodules
391
409
 
392
410
  @GeneralUtilities.check_arguments
393
411
  def git_commit(self, directory: str, message: str="Saved changes.", author_name: str = None, author_email: str = None, stage_all_changes: bool = True, no_changes_behavior: int = 0) -> str:
394
412
  """no_changes_behavior=0 => No commit; no_changes_behavior=1 => Commit anyway; no_changes_behavior=2 => Exception"""
413
+ self.assert_is_git_repository(directory)
395
414
  author_name = GeneralUtilities.str_none_safe(author_name).strip()
396
415
  author_email = GeneralUtilities.str_none_safe(author_email).strip()
397
416
  argument = ['commit', '--quiet', '--allow-empty', '--message', message]
@@ -423,29 +442,36 @@ class ScriptCollectionCore:
423
442
 
424
443
  @GeneralUtilities.check_arguments
425
444
  def git_create_tag(self, directory: str, target_for_tag: str, tag: str, sign: bool = False, message: str = None) -> None:
445
+ self.assert_is_git_repository(directory)
426
446
  argument = ["tag", tag, target_for_tag]
427
447
  if sign:
428
448
  if message is None:
429
449
  message = f"Created {target_for_tag}"
430
450
  argument.extend(["-s", '-m', message])
431
- self.run_program_argsasarray(
432
- "git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
451
+ self.run_program_argsasarray( "git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
433
452
 
434
453
  @GeneralUtilities.check_arguments
435
454
  def git_delete_tag(self, directory: str, tag: str) -> None:
455
+ self.assert_is_git_repository(directory)
436
456
  self.run_program_argsasarray("git", ["tag", "--delete", tag], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
437
457
 
438
458
  @GeneralUtilities.check_arguments
439
- def git_checkout(self, directory: str, branch: str) -> None:
459
+ def git_checkout(self, directory: str, branch: str,undo_all_changes_after_checkout:bool=True) -> None:
460
+ self.assert_is_git_repository(directory)
461
+ GeneralUtilities.assert_condition(self.git_repository_has_uncommitted_changes(directory),f"Repository '{directory}' has uncommitted changes..")
440
462
  self.run_program_argsasarray("git", ["checkout", branch], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
441
463
  self.run_program_argsasarray("git", ["submodule", "update", "--recursive"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
464
+ if undo_all_changes_after_checkout:
465
+ self.git_undo_all_changes(directory)
442
466
 
443
467
  @GeneralUtilities.check_arguments
444
468
  def git_merge_abort(self, directory: str) -> None:
469
+ self.assert_is_git_repository(directory)
445
470
  self.run_program_argsasarray("git", ["merge", "--abort"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
446
471
 
447
472
  @GeneralUtilities.check_arguments
448
473
  def git_merge(self, directory: str, sourcebranch: str, targetbranch: str, fastforward: bool = True, commit: bool = True, commit_message: str = None) -> str:
474
+ self.assert_is_git_repository(directory)
449
475
  self.git_checkout(directory, targetbranch)
450
476
  args = ["merge"]
451
477
  if not commit:
@@ -463,6 +489,7 @@ class ScriptCollectionCore:
463
489
  @GeneralUtilities.check_arguments
464
490
  def git_undo_all_changes(self, directory: str) -> None:
465
491
  """Caution: This function executes 'git clean -df'. This can delete files which maybe should not be deleted. Be aware of that."""
492
+ self.assert_is_git_repository(directory)
466
493
  self.git_unstage_all_changes(directory)
467
494
  self.git_discard_all_unstaged_changes(directory)
468
495
 
@@ -480,8 +507,9 @@ class ScriptCollectionCore:
480
507
  # clone
481
508
  self.git_clone(target_repository, source_repository, include_submodules=True, mirror=True)
482
509
 
483
- def get_git_submodules(self, folder: str) -> list[str]:
484
- e = self.run_program("git", "submodule status", folder)
510
+ def get_git_submodules(self, directory: str) -> list[str]:
511
+ self.assert_is_git_repository(directory)
512
+ e = self.run_program("git", "submodule status", directory)
485
513
  result = []
486
514
  for submodule_line in GeneralUtilities.string_to_lines(e[1], False, True):
487
515
  result.append(submodule_line.split(' ')[1])
@@ -489,6 +517,7 @@ class ScriptCollectionCore:
489
517
 
490
518
  @GeneralUtilities.check_arguments
491
519
  def file_is_git_ignored(self, file_in_repository: str, repositorybasefolder: str) -> None:
520
+ self.assert_is_git_repository(repositorybasefolder)
492
521
  exit_code = self.run_program_argsasarray("git", ['check-ignore', file_in_repository], repositorybasefolder, throw_exception_if_exitcode_is_not_zero=False, verbosity=0)[0]
493
522
  if (exit_code == 0):
494
523
  return True
@@ -498,28 +527,33 @@ class ScriptCollectionCore:
498
527
 
499
528
  @GeneralUtilities.check_arguments
500
529
  def git_discard_all_changes(self, repository: str) -> None:
530
+ self.assert_is_git_repository(repository)
501
531
  self.run_program_argsasarray("git", ["reset", "HEAD", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
502
532
  self.run_program_argsasarray("git", ["checkout", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
503
533
 
504
534
  @GeneralUtilities.check_arguments
505
535
  def git_get_current_branch_name(self, repository: str) -> str:
536
+ self.assert_is_git_repository(repository)
506
537
  result = self.run_program_argsasarray("git", ["rev-parse", "--abbrev-ref", "HEAD"], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
507
538
  return result[1].replace("\r", "").replace("\n", "")
508
539
 
509
540
  @GeneralUtilities.check_arguments
510
541
  def git_get_commitid_of_tag(self, repository: str, tag: str) -> str:
542
+ self.assert_is_git_repository(repository)
511
543
  stdout = self.run_program_argsasarray("git", ["rev-list", "-n", "1", tag], repository, verbosity=0)
512
544
  result = stdout[1].replace("\r", "").replace("\n", "")
513
545
  return result
514
546
 
515
547
  @GeneralUtilities.check_arguments
516
548
  def git_get_tags(self, repository: str) -> list[str]:
549
+ self.assert_is_git_repository(repository)
517
550
  tags = [line.replace("\r", "") for line in self.run_program_argsasarray(
518
551
  "git", ["tag"], repository)[1].split("\n") if len(line) > 0]
519
552
  return tags
520
553
 
521
554
  @GeneralUtilities.check_arguments
522
555
  def git_move_tags_to_another_branch(self, repository: str, tag_source_branch: str, tag_target_branch: str, sign: bool = False, message: str = None) -> None:
556
+ self.assert_is_git_repository(repository)
523
557
  tags = self.git_get_tags(repository)
524
558
  tags_count = len(tags)
525
559
  counter = 0
@@ -1856,7 +1890,7 @@ DNS = {domain}
1856
1890
  raise ValueError(f"python_package_is_available is not implemented yet for other sources than {default_source_address}.")
1857
1891
 
1858
1892
  @GeneralUtilities.check_arguments
1859
- def python_until_dotnet_package_is_available(self,package_name:str,package_version:str,source:str):
1893
+ def wait_until_python_package_is_available(self,package_name:str,package_version:str,source:str):
1860
1894
  while not self.python_package_is_available(package_name,package_version,source):
1861
1895
  time.sleep(5)
1862
1896
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ScriptCollection
3
- Version: 3.5.83
3
+ Version: 3.5.84
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
@@ -5,12 +5,12 @@ ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4b
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=DMAt3OV5-ydbKKFbc_1MV9i1Bv_1sK_2AsBez-_HJ-o,121187
8
+ ScriptCollection/ScriptCollectionCore.py,sha256=0W4WdCHN8FXmZbrdEWirYschKwJkFqdPNvWw2dwLG6c,123057
9
9
  ScriptCollection/TasksForCommonProjectStructure.py,sha256=n6og3gADK7oBd5_9F-XNKVlQ0bO9EL7irdOSJAh-Vtc,215940
10
10
  ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
11
11
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- ScriptCollection-3.5.83.dist-info/METADATA,sha256=4K38CjZq0Ik1dmTNilhSXT-uGpNbKMWl_tsovThshbA,7664
13
- ScriptCollection-3.5.83.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- ScriptCollection-3.5.83.dist-info/entry_points.txt,sha256=1jAL5AuB8mvdw2v-6E7wCZFThurQxchiQynL8DCi-Yg,3545
15
- ScriptCollection-3.5.83.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
- ScriptCollection-3.5.83.dist-info/RECORD,,
12
+ ScriptCollection-3.5.84.dist-info/METADATA,sha256=xs5tu_QAF5oTpfKaQI9fQP_9n5REeh8yXqh8lH4_5-k,7664
13
+ ScriptCollection-3.5.84.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ ScriptCollection-3.5.84.dist-info/entry_points.txt,sha256=1jAL5AuB8mvdw2v-6E7wCZFThurQxchiQynL8DCi-Yg,3545
15
+ ScriptCollection-3.5.84.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
16
+ ScriptCollection-3.5.84.dist-info/RECORD,,