]> Untitled Git - axy/ft/python04.git/commitdiff
Docstrings and type hints master
authorAxy <gilliardmarthey.axel@gmail.com>
Tue, 13 Jan 2026 17:32:02 +0000 (18:32 +0100)
committerAxy <gilliardmarthey.axel@gmail.com>
Tue, 13 Jan 2026 17:32:02 +0000 (18:32 +0100)
ex0/ft_ancient_text.py
ex1/ft_archive_creation.py
ex2/ft_stream_management.py
ex3/ft_vault_security.py
ex4/ft_crisis_response.py

index c924fb94113061e63b5a1b66b624ddcfa2ee8ae5..f9f44cc4b377e07ee29cea2bfca7600edb36f13d 100644 (file)
@@ -1,7 +1,13 @@
 import os
 
 
 import os
 
 
-def main():
+def main() -> None:
+    """
+    Recovers an ancient data fragment from the storage vault.
+
+    Reads from 'ancient_fragment.txt' and displays its content formatted
+    according to archive protocols. Handles missing storage vaults gracefully.
+    """
     filename = "ancient_fragment.txt"
     print("=== CYBER ARCHIVES - DATA RECOVERY SYSTEM ===")
     print(f"Accessing Storage Vault: {filename}")
     filename = "ancient_fragment.txt"
     print("=== CYBER ARCHIVES - DATA RECOVERY SYSTEM ===")
     print(f"Accessing Storage Vault: {filename}")
index 3e9e1beb15702fb9b1506828d1d42ba9875fb773..989a8ed152267289b67c0a090af3b04d269cb3cd 100644 (file)
@@ -1,4 +1,10 @@
-def main():
+def main() -> None:
+    """
+    Creates a new archive entry with preservation protocols.
+
+    Establishes 'new_discovery.txt' and inscribes critical data entries
+    including quantum algorithms and efficiency metrics using write mode.
+    """
     filename = "new_discovery.txt"
     print("=== CYBER ARCHIVES - PRESERVATION SYSTEM ===")
     print(f"Initializing new storage unit: {filename}")
     filename = "new_discovery.txt"
     print("=== CYBER ARCHIVES - PRESERVATION SYSTEM ===")
     print(f"Initializing new storage unit: {filename}")
index 3f4b0399d50b8c81bd3bd03614ceeaa3439b4c1e..3642b998565837db033c3a339eaee6c8b9ecfca3 100644 (file)
@@ -1,7 +1,13 @@
 import sys
 
 
 import sys
 
 
-def main():
+def main() -> None:
+    """
+    Manages communication channels for the Cyber Archives.
+
+    Demonstrates usage of standard input (stdin), standard output (stdout),
+    and standard error (stderr) to route messages and alerts appropriately.
+    """
     print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===")
 
     arch_id = input("Input Stream active. Enter archivist ID: ")
     print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===")
 
     arch_id = input("Input Stream active. Enter archivist ID: ")
index 008ede98f928b8a6da744df70113d2a7387ac240..5e9821589a768c01fdb327ad4e46eea9b5066f02 100644 (file)
@@ -1,4 +1,11 @@
-def main():
+def main() -> None:
+    """
+    Demonstrates secure vault access using context managers.
+
+    Uses the 'with' statement to ensure safe file operations for both
+    reading classified data and preserving new security protocols,
+    guaranteeing resources are properly released.
+    """
     print("=== CYBER ARCHIVES - VAULT SECURITY SYSTEM ===")
     print("Initiating secure vault access...")
     print("Vault connection established with failsafe protocols")
     print("=== CYBER ARCHIVES - VAULT SECURITY SYSTEM ===")
     print("Initiating secure vault access...")
     print("Vault connection established with failsafe protocols")
index ce0e6cf4901dd246b0cd906dc56196cfc569fc53..6353f49f8db23c41a3d06f76873bc27ff8a9b8b7 100644 (file)
@@ -1,7 +1,16 @@
 import os
 
 
 import os
 
 
-def crisis_handler(filename):
+def crisis_handler(filename: str) -> None:
+    """
+    Handles archive access attempts and manages potential crises.
+
+    Args:
+        filename (str): The name of the file (vault) to access.
+
+    Handles FileNotFoundError and PermissionError with appropriate
+    response protocols.
+    """
     # Determine log prefix
     if filename == "standard_archive.txt":
         print(f"ROUTINE ACCESS: Attempting access to '{filename}'...")
     # Determine log prefix
     if filename == "standard_archive.txt":
         print(f"ROUTINE ACCESS: Attempting access to '{filename}'...")
@@ -24,7 +33,13 @@ def crisis_handler(filename):
         print("STATUS: Crisis handled")
 
 
         print("STATUS: Crisis handled")
 
 
-def main():
+def main() -> None:
+    """
+    Executes a simulation of various crisis scenarios.
+
+    Tests the crisis_handler against missing files, security violations,
+    and standard access to ensure system stability.
+    """
     print("=== CYBER ARCHIVES - CRISIS RESPONSE SYSTEM ===")
 
     # Scenario 1: Missing Archive
     print("=== CYBER ARCHIVES - CRISIS RESPONSE SYSTEM ===")
 
     # Scenario 1: Missing Archive