stouputils 1.12.1__tar.gz → 1.12.2__tar.gz

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.
Files changed (139) hide show
  1. {stouputils-1.12.1 → stouputils-1.12.2}/PKG-INFO +1 -2
  2. {stouputils-1.12.1 → stouputils-1.12.2}/pyproject.toml +1 -2
  3. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/__init__.py +4 -4
  4. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/__init__.pyi +1 -0
  5. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/__main__.py +5 -5
  6. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/print.py +0 -58
  7. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/print.pyi +0 -10
  8. stouputils-1.12.2/stouputils/version_pkg.py +189 -0
  9. stouputils-1.12.2/stouputils/version_pkg.pyi +15 -0
  10. {stouputils-1.12.1 → stouputils-1.12.2}/README.md +0 -0
  11. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/_deprecated.py +0 -0
  12. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/_deprecated.pyi +0 -0
  13. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/all_doctests.py +0 -0
  14. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/all_doctests.pyi +0 -0
  15. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/__init__.py +0 -0
  16. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/__init__.pyi +0 -0
  17. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/automatic_docs.py +0 -0
  18. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/automatic_docs.pyi +0 -0
  19. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/__init__.py +0 -0
  20. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/__init__.pyi +0 -0
  21. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/config.py +0 -0
  22. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/config.pyi +0 -0
  23. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/image.py +0 -0
  24. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/image.pyi +0 -0
  25. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/video.py +0 -0
  26. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/applications/upscaler/video.pyi +0 -0
  27. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/archive.py +0 -0
  28. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/archive.pyi +0 -0
  29. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/backup.py +0 -0
  30. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/backup.pyi +0 -0
  31. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/collections.py +0 -0
  32. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/collections.pyi +0 -0
  33. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/__init__.py +0 -0
  34. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/__init__.pyi +0 -0
  35. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/cd_utils.py +0 -0
  36. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/cd_utils.pyi +0 -0
  37. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/github.py +0 -0
  38. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/github.pyi +0 -0
  39. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/pypi.py +0 -0
  40. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/pypi.pyi +0 -0
  41. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/pyproject.py +0 -0
  42. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/pyproject.pyi +0 -0
  43. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/stubs.py +0 -0
  44. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/continuous_delivery/stubs.pyi +0 -0
  45. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/ctx.py +0 -0
  46. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/ctx.pyi +0 -0
  47. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/config/get.py +0 -0
  48. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/config/set.py +0 -0
  49. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/__init__.py +0 -0
  50. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
  51. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
  52. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
  53. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
  54. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/blur.py +0 -0
  55. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/brightness.py +0 -0
  56. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/canny.py +0 -0
  57. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/clahe.py +0 -0
  58. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/common.py +0 -0
  59. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/contrast.py +0 -0
  60. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
  61. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/denoise.py +0 -0
  62. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
  63. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/invert.py +0 -0
  64. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
  65. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
  66. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/noise.py +0 -0
  67. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/normalize.py +0 -0
  68. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
  69. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/resize.py +0 -0
  70. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/rotation.py +0 -0
  71. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
  72. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
  73. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/shearing.py +0 -0
  74. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/threshold.py +0 -0
  75. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/translation.py +0 -0
  76. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image/zoom.py +0 -0
  77. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
  78. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
  79. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
  80. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/data_processing/technique.py +0 -0
  81. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/__init__.py +0 -0
  82. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/dataset.py +0 -0
  83. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/dataset_loader.py +0 -0
  84. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
  85. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/image_loader.py +0 -0
  86. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/dataset/xy_tuple.py +0 -0
  87. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/metric_dictionnary.py +0 -0
  88. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/metric_utils.py +0 -0
  89. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/mlflow_utils.py +0 -0
  90. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/abstract_model.py +0 -0
  91. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/all.py +0 -0
  92. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/base_keras.py +0 -0
  93. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/all.py +0 -0
  94. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/convnext.py +0 -0
  95. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/densenet.py +0 -0
  96. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/efficientnet.py +0 -0
  97. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/mobilenet.py +0 -0
  98. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/resnet.py +0 -0
  99. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/squeezenet.py +0 -0
  100. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/vgg.py +0 -0
  101. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras/xception.py +0 -0
  102. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
  103. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
  104. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
  105. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
  106. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
  107. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
  108. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
  109. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
  110. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
  111. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/model_interface.py +0 -0
  112. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/models/sandbox.py +0 -0
  113. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/range_tuple.py +0 -0
  114. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/scripts/augment_dataset.py +0 -0
  115. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
  116. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
  117. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/scripts/routine.py +0 -0
  118. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/data_science/utils.py +0 -0
  119. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/decorators.py +0 -0
  120. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/decorators.pyi +0 -0
  121. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/image.py +0 -0
  122. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/image.pyi +0 -0
  123. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/__init__.py +0 -0
  124. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/__init__.pyi +0 -0
  125. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/common.py +0 -0
  126. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/common.pyi +0 -0
  127. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/downloader.py +0 -0
  128. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/downloader.pyi +0 -0
  129. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/linux.py +0 -0
  130. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/linux.pyi +0 -0
  131. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/main.py +0 -0
  132. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/main.pyi +0 -0
  133. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/windows.py +0 -0
  134. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/installer/windows.pyi +0 -0
  135. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/io.py +0 -0
  136. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/io.pyi +0 -0
  137. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/parallel.py +0 -0
  138. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/parallel.pyi +0 -0
  139. {stouputils-1.12.1 → stouputils-1.12.2}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: stouputils
3
- Version: 1.12.1
3
+ Version: 1.12.2
4
4
  Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
5
5
  Keywords: utilities,tools,helpers,development,python
6
6
  Author: Stoupy51
@@ -25,7 +25,6 @@ Requires-Dist: mlflow ; extra == 'data-science'
25
25
  Requires-Dist: tensorflow ; extra == 'data-science'
26
26
  Requires-Dist: scikit-learn ; extra == 'data-science'
27
27
  Requires-Dist: pywavelets ; extra == 'data-science'
28
- Requires-Dist: mypy ; extra == 'docs'
29
28
  Requires-Dist: m2r2 ; extra == 'docs'
30
29
  Requires-Dist: myst-parser ; extra == 'docs'
31
30
  Requires-Dist: sphinx-copybutton ; extra == 'docs'
@@ -10,7 +10,7 @@ ignore-vcs = true
10
10
 
11
11
  [project]
12
12
  name = "stouputils"
13
- version = "1.12.1"
13
+ version = "1.12.2"
14
14
  description = "Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more."
15
15
  readme = "README.md"
16
16
  keywords = ["utilities", "tools", "helpers", "development", "python"]
@@ -38,7 +38,6 @@ authors = [
38
38
 
39
39
  [project.optional-dependencies]
40
40
  docs = [
41
- "mypy",
42
41
  "m2r2",
43
42
  "myst_parser",
44
43
  "sphinx_copybutton",
@@ -14,10 +14,9 @@ Key Features:
14
14
  - Doctests utilities
15
15
 
16
16
  """
17
- # ruff: noqa: F403
18
-
19
17
  # Version (handle case where the package is not installed)
20
- from importlib.metadata import PackageNotFoundError, version
18
+ from importlib.metadata import PackageNotFoundError
19
+ from importlib.metadata import version as importlib_version
21
20
 
22
21
  # Imports
23
22
  from ._deprecated import *
@@ -32,9 +31,10 @@ from .image import *
32
31
  from .io import *
33
32
  from .parallel import *
34
33
  from .print import *
34
+ from .version_pkg import *
35
35
 
36
36
  try:
37
- __version__: str = version("stouputils")
37
+ __version__: str = importlib_version("stouputils")
38
38
  except PackageNotFoundError:
39
39
  __version__: str = "0.0.0-dev"
40
40
 
@@ -10,5 +10,6 @@ from .image import *
10
10
  from .io import *
11
11
  from .parallel import *
12
12
  from .print import *
13
+ from .version_pkg import *
13
14
 
14
15
  __version__: str
@@ -11,7 +11,8 @@ from .all_doctests import launch_tests
11
11
  from .archive import archive_cli
12
12
  from .backup import backup_cli
13
13
  from .decorators import handle_error
14
- from .print import CYAN, GREEN, RESET, show_version
14
+ from .print import CYAN, GREEN, RESET
15
+ from .version_pkg import show_version_cli
15
16
 
16
17
  # Argument Parser Setup for Auto-Completion
17
18
  parser = argparse.ArgumentParser(prog="stouputils", add_help=False)
@@ -28,9 +29,7 @@ def main() -> None:
28
29
 
29
30
  # Print the version of stouputils and its dependencies
30
31
  if second_arg in ("--version", "-v", "version", "show_version"):
31
- if len(sys.argv) >= 3:
32
- return show_version(sys.argv[2])
33
- return show_version()
32
+ return show_version_cli()
34
33
 
35
34
  # Handle "all_doctests" command
36
35
  if second_arg == "all_doctests":
@@ -68,7 +67,8 @@ def main() -> None:
68
67
  {CYAN}Usage:{RESET} stouputils <command> [options]
69
68
 
70
69
  {CYAN}Available commands:{RESET}
71
- {GREEN}--version, -v{RESET} [pkg] Show version information (optionally for a specific package)
70
+ {GREEN}--version, -v{RESET} [pkg] [-t <depth>]
71
+ Show version information (optionally for a specific package)
72
72
  {GREEN}all_doctests{RESET} [dir] Run all doctests in the specified directory
73
73
  {GREEN}archive{RESET} --help Archive utilities (make, repair)
74
74
  {GREEN}backup{RESET} --help Backup utilities (delta, consolidate, limit)
@@ -432,64 +432,6 @@ def current_time() -> str:
432
432
  return time.strftime("%H:%M:%S")
433
433
 
434
434
 
435
- def show_version(main_package: str = "stouputils", primary_color: str = CYAN, secondary_color: str = GREEN) -> None:
436
- """ Print the version of the main package and its dependencies.
437
-
438
- Used by the "stouputils --version" command.
439
-
440
- Args:
441
- main_package (str): Name of the main package to show version for
442
- primary_color (str): Color to use for the primary package name
443
- secondary_color (str): Color to use for the secondary package names
444
- """
445
- # Imports
446
- from importlib.metadata import requires, version
447
- def ver(package_name: str) -> str:
448
- try:
449
- return version(package_name)
450
- except Exception:
451
- return ""
452
-
453
- # Get dependencies dynamically and extract package names from requirements (e.g., "tqdm>=4.0.0" -> "tqdm")
454
- deps: list[str] = requires(main_package) or []
455
- dep_names: list[str] = sorted([
456
- dep
457
- .split(">")[0]
458
- .split("<")[0]
459
- .split("=")[0]
460
- .split("[")[0]
461
- for dep in deps
462
- ])
463
- all_deps: list[tuple[str, str]] = [
464
- (x, ver(x).split("version: ")[-1])
465
- for x in (main_package, *dep_names)
466
- ]
467
- all_deps = [pair for pair in all_deps if pair[1]] # Filter out packages with no version found
468
- longest_name_length: int = max(len(name) for name, _ in all_deps)
469
- longest_version_length: int = max(len(ver) for _, ver in all_deps)
470
-
471
- # Get Python version
472
- python_version: str = f" Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} "
473
- minimum_separator_length: int = len(python_version) + 10 # Always at least 5 dashes on each side
474
- separator_length: int = max(minimum_separator_length, longest_name_length + longest_version_length + 4)
475
- python_text_length: int = len(python_version)
476
- left_dashes: int = (separator_length - python_text_length) // 2
477
- right_dashes: int = separator_length - python_text_length - left_dashes
478
- separator_with_python: str = "─" * left_dashes + python_version + "─" * right_dashes
479
- separator: str = "─" * separator_length
480
-
481
- for pkg, v in all_deps:
482
- pkg_spacing: str = " " * (longest_name_length - len(pkg))
483
-
484
- # Highlight the main package with a different style
485
- if pkg == main_package:
486
- print(f"{primary_color}{separator_with_python}{RESET}")
487
- print(f"{primary_color}{pkg}{pkg_spacing} {secondary_color}v{v}{RESET}")
488
- print(f"{primary_color}{separator}{RESET}")
489
- else:
490
- print(f"{primary_color}{pkg}{pkg_spacing} {secondary_color}v{v}{RESET}")
491
- return
492
-
493
435
  # Test the print functions
494
436
  if __name__ == "__main__":
495
437
  info("Hello", "World")
@@ -134,13 +134,3 @@ def is_same_print(*args: Any, **kwargs: Any) -> bool:
134
134
  """ Checks if the current print call is the same as the previous one. """
135
135
  def current_time() -> str:
136
136
  ''' Get the current time as "HH:MM:SS" if less than 24 hours since import, else "YYYY-MM-DD HH:MM:SS" '''
137
- def show_version(main_package: str = 'stouputils', primary_color: str = ..., secondary_color: str = ...) -> None:
138
- ''' Print the version of the main package and its dependencies.
139
-
140
- \tUsed by the "stouputils --version" command.
141
-
142
- \tArgs:
143
- \t\tmain_package\t\t\t(str):\t\t\tName of the main package to show version for
144
- \t\tprimary_color\t\t\t(str):\t\t\tColor to use for the primary package name
145
- \t\tsecondary_color\t\t\t(str):\t\t\tColor to use for the secondary package names
146
- \t'''
@@ -0,0 +1,189 @@
1
+ """
2
+ This module provides utility functions for printing package version information
3
+ in a structured format, including the main package and its dependencies.
4
+
5
+ Functions:
6
+ - show_version: Print the version of the main package and its dependencies.
7
+ """
8
+
9
+ # Imports
10
+ import sys
11
+
12
+ from .print import CYAN, GREEN, RESET, YELLOW
13
+
14
+
15
+ # Show version function
16
+ def show_version(main_package: str = "stouputils", primary_color: str = CYAN, secondary_color: str = GREEN, max_depth: int = 2) -> None:
17
+ """ Print the version of the main package and its dependencies.
18
+
19
+ Used by the "stouputils --version" command.
20
+
21
+ Args:
22
+ main_package (str): Name of the main package to show version for
23
+ primary_color (str): Color to use for the primary package name
24
+ secondary_color (str): Color to use for the secondary package names
25
+ max_depth (int): Maximum depth for dependency tree (<= 2 for flat, >=3 for tree)
26
+ """
27
+ # Imports
28
+ from importlib.metadata import requires, version
29
+ def ver(package_name: str) -> str:
30
+ try:
31
+ return version(package_name)
32
+ except Exception:
33
+ return ""
34
+
35
+ def get_deps(package_name: str) -> list[str]:
36
+ """ Get the list of dependency names for a package """
37
+ try:
38
+ deps: list[str] = requires(package_name) or []
39
+ # Remove duplicates while preserving order, then sort
40
+ unique_deps: list[str] = list(dict.fromkeys([
41
+ dep
42
+ .split(">")[0]
43
+ .split("<")[0]
44
+ .split("=")[0]
45
+ .split("[")[0]
46
+ .split(";")[0]
47
+ .strip()
48
+ for dep in deps
49
+ ]))
50
+ return sorted(unique_deps)
51
+ except Exception:
52
+ return []
53
+
54
+ def print_tree(package_name: str, prefix: str = "", is_last: bool = True, visited: set[str] | None = None, fully_displayed: set[str] | None = None, depth: int = 0, max_depth: int = 3) -> None:
55
+ """ Recursively print the dependency tree """
56
+ if visited is None:
57
+ visited = set()
58
+ if fully_displayed is None:
59
+ fully_displayed = set()
60
+
61
+ # Prevent infinite recursion and limit depth
62
+ if package_name in visited or depth > max_depth:
63
+ return
64
+ visited.add(package_name)
65
+
66
+ # Get version
67
+ v: str = ver(package_name).split("version: ")[-1]
68
+ if not v:
69
+ return
70
+
71
+ # Determine the tree characters
72
+ connector: str = "└── " if is_last else "├── "
73
+
74
+ # Check if this package was already fully displayed
75
+ already_shown: bool = package_name in fully_displayed
76
+
77
+ # Print current package
78
+ if depth == 0:
79
+ print(f"{primary_color}{package_name} {secondary_color}v{v}{RESET}")
80
+ else:
81
+ if already_shown:
82
+ print(f"{prefix}{connector}{primary_color}{package_name} {secondary_color}v{v} {YELLOW}[Already shown ^]{RESET}")
83
+ # Still mark as fully displayed even when already shown
84
+ fully_displayed.add(package_name)
85
+ return
86
+ else:
87
+ print(f"{prefix}{connector}{primary_color}{package_name} {secondary_color}v{v}{RESET}")
88
+
89
+ # Get dependencies
90
+ deps: list[str] = get_deps(package_name)
91
+
92
+ # Filter dependencies that will actually be displayed (have a version)
93
+ valid_deps: list[str] = [dep for dep in deps if ver(dep)]
94
+
95
+ # Print dependencies recursively
96
+ for i, dep in enumerate(valid_deps):
97
+ # Determine if this is the last element to display
98
+ is_last_dep: bool = (i == len(valid_deps) - 1)
99
+
100
+ # Extension is based on whether the CURRENT node is last, not the child
101
+ extension: str = " " if is_last else "│ "
102
+ new_prefix: str = prefix + extension if depth > 0 else ""
103
+ print_tree(dep, new_prefix, is_last_dep, visited.copy(), fully_displayed, depth + 1, max_depth)
104
+
105
+ # Mark this package as fully displayed (with all its dependencies)
106
+ fully_displayed.add(package_name)
107
+
108
+ # Get Python version header
109
+ python_version: str = f" Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} "
110
+
111
+ if max_depth >= 3:
112
+ # Display as tree structure
113
+ minimum_separator_length: int = len(python_version) + 10
114
+ separator_length: int = minimum_separator_length
115
+ python_text_length: int = len(python_version)
116
+ left_dashes: int = (separator_length - python_text_length) // 2
117
+ right_dashes: int = separator_length - python_text_length - left_dashes
118
+ separator_with_python: str = "─" * left_dashes + python_version + "─" * right_dashes
119
+ separator: str = "─" * separator_length
120
+
121
+ print(f"{primary_color}{separator_with_python}{RESET}")
122
+ print_tree(main_package, max_depth=max_depth - 1)
123
+ print(f"{primary_color}{separator}{RESET}")
124
+ else:
125
+ # Display as flat list (original behavior)
126
+ deps: list[str] = requires(main_package) or []
127
+ dep_names: list[str] = sorted([
128
+ dep
129
+ .split(">")[0]
130
+ .split("<")[0]
131
+ .split("=")[0]
132
+ .split("[")[0]
133
+ for dep in deps
134
+ ])
135
+ all_deps: list[tuple[str, str]] = [
136
+ (x, ver(x).split("version: ")[-1])
137
+ for x in (main_package, *dep_names)
138
+ ]
139
+ all_deps = [pair for pair in all_deps if pair[1]] # Filter out packages with no version found
140
+ longest_name_length: int = max(len(name) for name, _ in all_deps)
141
+ longest_version_length: int = max(len(ver) for _, ver in all_deps)
142
+
143
+ minimum_separator_length: int = len(python_version) + 10 # Always at least 5 dashes on each side
144
+ separator_length: int = max(minimum_separator_length, longest_name_length + longest_version_length + 4)
145
+ python_text_length: int = len(python_version)
146
+ left_dashes: int = (separator_length - python_text_length) // 2
147
+ right_dashes: int = separator_length - python_text_length - left_dashes
148
+ separator_with_python: str = "─" * left_dashes + python_version + "─" * right_dashes
149
+ separator: str = "─" * separator_length
150
+
151
+ for pkg, v in all_deps:
152
+ pkg_spacing: str = " " * (longest_name_length - len(pkg))
153
+
154
+ # Highlight the main package with a different style
155
+ if pkg == main_package:
156
+ print(f"{primary_color}{separator_with_python}{RESET}")
157
+ print(f"{primary_color}{pkg}{pkg_spacing} {secondary_color}v{v}{RESET}")
158
+ print(f"{primary_color}{separator}{RESET}")
159
+ else:
160
+ print(f"{primary_color}{pkg}{pkg_spacing} {secondary_color}v{v}{RESET}")
161
+ return
162
+
163
+ # Show version cli
164
+ def show_version_cli() -> None:
165
+ """ Handle the "stouputils --version" CLI command """
166
+ # Determine max depth (flat or tree structure)
167
+ max_depth: int = 2 # Flat by default
168
+
169
+ # Check for tree argument
170
+ if "--tree" in sys.argv or "-t" in sys.argv:
171
+ # Find position of tree argument
172
+ pos: int = sys.argv.index("--tree") if "--tree" in sys.argv else sys.argv.index("-t")
173
+
174
+ # Check for depth argument
175
+ if pos + 1 < len(sys.argv):
176
+ try:
177
+ max_depth = int(sys.argv[pos + 1])
178
+ sys.argv.pop(pos + 1) # Remove depth argument
179
+ except ValueError:
180
+ pass # Keep default if conversion fails
181
+ sys.argv.pop(pos) # Remove the --tree/-t argument
182
+
183
+ # Handle specific package argument
184
+ if len(sys.argv) >= 3 and not sys.argv[2].startswith("-"):
185
+ return show_version(sys.argv[2], max_depth=max_depth)
186
+
187
+ # Else, show default package version
188
+ return show_version(max_depth=max_depth)
189
+
@@ -0,0 +1,15 @@
1
+ from .print import CYAN as CYAN, GREEN as GREEN, RESET as RESET, YELLOW as YELLOW
2
+
3
+ def show_version(main_package: str = 'stouputils', primary_color: str = ..., secondary_color: str = ..., max_depth: int = 2) -> None:
4
+ ''' Print the version of the main package and its dependencies.
5
+
6
+ \tUsed by the "stouputils --version" command.
7
+
8
+ \tArgs:
9
+ \t\tmain_package\t(str):\tName of the main package to show version for
10
+ \t\tprimary_color\t(str):\tColor to use for the primary package name
11
+ \t\tsecondary_color\t(str):\tColor to use for the secondary package names
12
+ \t\tmax_depth\t\t(int):\tMaximum depth for dependency tree (<= 2 for flat, >=3 for tree)
13
+ \t'''
14
+ def show_version_cli() -> None:
15
+ ''' Handle the "stouputils --version" CLI command '''
File without changes