orb-package-manager 0.1.0__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.
orb.py ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse # Legge gli argomenti
4
+ import shutil # Shutil controlla se un programma esiste nel path
5
+ import subprocess # Esegue i comandi
6
+ import sys # Output per gli errori
7
+ from dataclasses import dataclass # Shortcut per creare classi
8
+ from enum import Enum # Per definire un insieme chiuso di valori
9
+
10
+
11
+ # Definisce gli unici 3 valori possibili
12
+ class Manager(Enum):
13
+ PACMAN = "pacman"
14
+ PARU = "paru"
15
+ FLATPAK = "flatpak" # Corretto da "flatpack" a "flatpak"
16
+
17
+
18
+ # Definisce come evocare i package manager
19
+ @dataclass
20
+ class Backend:
21
+ manager: Manager
22
+ binary: str
23
+ needs_sudo: bool
24
+ install_args: list[str]
25
+
26
+
27
+ # --- ECCO COSA MANCAVA: LA LISTA BACKENDS ---
28
+ BACKENDS = [
29
+ Backend(Manager.PACMAN, "pacman", True, ["-S"]),
30
+ Backend(Manager.PARU, "paru", False, ["-S"]),
31
+ Backend(Manager.FLATPAK, "flatpak", False, ["install", "-y"]),
32
+ ]
33
+ # --------------------------------------------
34
+
35
+
36
+ def available_backends() -> list[Backend]: # Corretto "avalable" in "available"
37
+ return [b for b in BACKENDS if shutil.which(b.binary)]
38
+
39
+
40
+ def ask_choice(backends: list[Backend]) -> Backend:
41
+ print("available options:") # Corretto "avalable"
42
+ for i, b in enumerate(backends, start=1):
43
+ print(f"[{i}] {b.manager.value}")
44
+ while True:
45
+ raw = input(
46
+ f"select an option [1-{len(backends)}]: "
47
+ ).strip() # Corretto "options" e "--"
48
+ if raw.isdigit() and 1 <= int(raw) <= len(backends):
49
+ return backends[int(raw) - 1]
50
+ print("invalid choice, try again.")
51
+
52
+
53
+ def confirm(prompt: str = "proceed with the installation?") -> bool:
54
+ return input(f"{prompt} [S/n]: ").strip().lower() in (
55
+ "",
56
+ "s",
57
+ "y",
58
+ "yes",
59
+ ) # Aggiunti i due punti
60
+
61
+
62
+ def install(package: str) -> int:
63
+ backends = available_backends() # Corretto "avalable"
64
+ if not backends:
65
+ print("error: no supported package manager found", file=sys.stderr)
66
+ return 1
67
+ backend = ask_choice(backends)
68
+
69
+ if not confirm():
70
+ print("aborted.")
71
+ return 0
72
+ cmd = [backend.binary, *backend.install_args, package]
73
+ if backend.needs_sudo and shutil.which("sudo"):
74
+ cmd = ["sudo", *cmd]
75
+ print("installing...")
76
+ rc = subprocess.call(cmd)
77
+ if rc == 0:
78
+ print("installation complete") # Corretto "complite"
79
+ else:
80
+ print(f"error: exit code {rc}", file=sys.stderr)
81
+ return rc
82
+
83
+
84
+ def main(argv: list[str] | None = None) -> int:
85
+ parser = argparse.ArgumentParser(prog="orb", description="Unified package manager")
86
+ parser.add_argument("-S", "--install", metavar="PKG", help="install a package")
87
+ args = parser.parse_args(argv)
88
+
89
+ if args.install:
90
+ return install(args.install)
91
+
92
+ parser.print_help()
93
+ return 1
94
+
95
+
96
+ if __name__ == "__main__":
97
+ sys.exit(main())
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: orb-package-manager
3
+ Version: 0.1.0
4
+ Summary: A custom package manager that unifies pacman, yay, and flatpak.
5
+ Author: Hamuz
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+
9
+ # Orb-package-manager
@@ -0,0 +1,6 @@
1
+ orb.py,sha256=CnAhIR5Ix1xBaZjEtO-iy1n1cgm0lTdgNKYHxrguAKw,2844
2
+ orb_package_manager-0.1.0.dist-info/METADATA,sha256=J43PNPwILqhpjpTlyKkH-eIB11060eMAjQeU4yjLGE0,236
3
+ orb_package_manager-0.1.0.dist-info/WHEEL,sha256=a-udL2m4V_6Yn8b-uKzWb12RjRxwwMo6ohYFM24tpaY,91
4
+ orb_package_manager-0.1.0.dist-info/entry_points.txt,sha256=qmZaVEfgAlX7Qr_-UxgyzdktgGW0gGEX5u95vc9MzpI,33
5
+ orb_package_manager-0.1.0.dist-info/top_level.txt,sha256=V6q4S2w5BYzKmnRsLUOmLyYnFLmf07EEuJ9wcsa2bWg,4
6
+ orb_package_manager-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ orb = orb:main