From: Axy Date: Mon, 19 Jan 2026 15:21:56 +0000 (+0100) Subject: clean slate X-Git-Url: https://git.uwuaxy.net/?a=commitdiff_plain;h=9991b51c12caf30d557cc4b07b819d7843c47b18;p=axy%2Fft%2Fpython04.git clean slate --- diff --git a/ex0/ft_ancient_text.py b/ex0/ft_ancient_text.py deleted file mode 100644 index f9f44cc..0000000 --- a/ex0/ft_ancient_text.py +++ /dev/null @@ -1,31 +0,0 @@ -import os - - -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}") - - if not os.path.exists(filename): - print("ERROR: Storage vault not found. Run data generator first.") - return - - try: - print("Connection established...") - print("RECOVERED DATA:") - with open(filename, "r") as f: - content = f.read().strip() - print(content) - print("Data recovery complete. Storage unit disconnected.") - except Exception as e: - print(f"Error accessing vault: {e}") - - -if __name__ == "__main__": - main() diff --git a/ex1/ft_archive_creation.py b/ex1/ft_archive_creation.py deleted file mode 100644 index 989a8ed..0000000 --- a/ex1/ft_archive_creation.py +++ /dev/null @@ -1,34 +0,0 @@ -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}") - - try: - print("Storage unit created successfully...") - print("Inscribing preservation data...") - - with open(filename, "w") as f: - entries = [ - "[ENTRY 001] New quantum algorithm discovered", - "[ENTRY 002] Efficiency increased by 347%", - "[ENTRY 003] Archived by Data Archivist trainee", - ] - for entry in entries: - f.write(entry + "\n") - print(entry) - - print("Data inscription complete. Storage unit sealed.") - print(f"Archive '{filename}' ready for long-term preservation.") - - except Exception as e: - print(f"Error: {e}") - - -if __name__ == "__main__": - main() diff --git a/ex2/ft_stream_management.py b/ex2/ft_stream_management.py deleted file mode 100644 index 3642b99..0000000 --- a/ex2/ft_stream_management.py +++ /dev/null @@ -1,26 +0,0 @@ -import sys - - -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: ") - status = input("Input Stream active. Enter status report: ") - - sys.stdout.write(f"[STANDARD] Archive status from {arch_id}: {status}\n") - sys.stderr.write( - "[ALERT] System diagnostic: Communication channels verified\n" - ) - sys.stdout.write("[STANDARD] Data transmission complete\n") - - print("Three-channel communication test successful.") - - -if __name__ == "__main__": - main() diff --git a/ex3/ft_vault_security.py b/ex3/ft_vault_security.py deleted file mode 100644 index 5e98215..0000000 --- a/ex3/ft_vault_security.py +++ /dev/null @@ -1,36 +0,0 @@ -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") - - # Secure Extraction (Read) - print("SECURE EXTRACTION:") - try: - with open("classified_data.txt", "r") as f: - print(f.read().strip()) - except FileNotFoundError: - print("Error: classified_data.txt not found") - - # Secure Preservation (Write) - print("SECURE PRESERVATION:") - try: - with open("security_protocols.txt", "w") as f: - data = "[CLASSIFIED] New security protocols archived" - f.write(data) - print(data) - except Exception as e: - print(f"Error writing to vault: {e}") - - print("Vault automatically sealed upon completion") - print("All vault operations completed with maximum security.") - - -if __name__ == "__main__": - main() diff --git a/ex4/ft_crisis_response.py b/ex4/ft_crisis_response.py deleted file mode 100644 index 6353f49..0000000 --- a/ex4/ft_crisis_response.py +++ /dev/null @@ -1,76 +0,0 @@ -import os - - -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}'...") - else: - print(f"CRISIS ALERT: Attempting access to '{filename}'...") - - try: - with open(filename, "r") as f: - content = f.read().strip() - print(f'SUCCESS: Archive recovered - "{content}"') - print("STATUS: Normal operations resumed") - except FileNotFoundError: - print("RESPONSE: Archive not found in storage matrix") - print("STATUS: Crisis handled, system stable") - except PermissionError: - print("RESPONSE: Security protocols deny access") - print("STATUS: Crisis handled, security maintained") - except Exception as e: - print(f"RESPONSE: Unexpected error: {e}") - print("STATUS: Crisis handled") - - -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 - crisis_handler("lost_archive.txt") - - # Scenario 2: Security Violation (Simulated) - vault_filename = "classified_vault.txt" - try: - # Setup: Create and lock the vault - with open(vault_filename, "w") as f: - f.write("TOP SECRET") - os.chmod(vault_filename, 0o000) # Make unreadable - - crisis_handler(vault_filename) - - except OSError as e: - print(f"Test setup failed: {e}") - finally: - # Cleanup: Unlock and remove - if os.path.exists(vault_filename): - try: - os.chmod(vault_filename, 0o666) - os.remove(vault_filename) - except OSError: - pass - - # Scenario 3: Standard Access - crisis_handler("standard_archive.txt") - - print("All crisis scenarios handled successfully. Archives secure.") - - -if __name__ == "__main__": - main()