mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
Compare commits
5 Commits
bf3fec4335
...
e95f041f50
| Author | SHA1 | Date | |
|---|---|---|---|
| e95f041f50 | |||
| 194fdc1beb | |||
| ae3ae15fdb | |||
| 2bafef8574 | |||
| 1b068c2b2b |
15
04/ex0/ft_ancient_text.py
Normal file
15
04/ex0/ft_ancient_text.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
def read_ancient_text() -> None:
|
||||||
|
try:
|
||||||
|
print("Accessing Storage Vault: ancient_fragment.txt")
|
||||||
|
vault = open("ancient_fragment.txt", "r")
|
||||||
|
print("Connection establish...")
|
||||||
|
print("\nRECOVERED DATA:")
|
||||||
|
print(vault.read())
|
||||||
|
vault.close()
|
||||||
|
print("\nData recovery complete. Storage unit disconnected.")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("ERROR: Storage vault not found.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
read_ancient_text()
|
||||||
22
04/ex1/ft_archive_creation.py
Normal file
22
04/ex1/ft_archive_creation.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
def create_new_discovery() -> None:
|
||||||
|
print("=== CYBER ARCHIVES - PRESERVATION SYSTEM ===")
|
||||||
|
try:
|
||||||
|
print("\nInitializing new storage unit: new_discovery.txt")
|
||||||
|
file = open("new_discovery.txt", "w")
|
||||||
|
print("Storage unit created successfully...")
|
||||||
|
print("\nInscribing preservation data...")
|
||||||
|
print("[ENTRY 001] New quantum algorithm discovered\n\
|
||||||
|
[ENTRY 002] Efficiency increased by 347%\n\
|
||||||
|
[ENTRY 003] Archived by Data Archivist trainee")
|
||||||
|
file.write("[ENTRY 001] New quantum algorithm discovered\n\
|
||||||
|
[ENTRY 002] Efficiency increased by 347%\n\
|
||||||
|
[ENTRY 003] Archived by Data Archivist trainee")
|
||||||
|
file.close()
|
||||||
|
print("\nData inscription complete. Storage unit sealed.")
|
||||||
|
print("Archive 'new_discovery.txt' ready for long-term preservation.")
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
create_new_discovery()
|
||||||
21
04/ex2/ft_stream_management.py
Normal file
21
04/ex2/ft_stream_management.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def communication_system() -> None:
|
||||||
|
print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===")
|
||||||
|
sys.stdout.write("\nInput Stream active. Enter archivist ID: ")
|
||||||
|
archivist_id = input()
|
||||||
|
sys.stdout.write("Input Stream active. Enter status report: ")
|
||||||
|
status_report = input()
|
||||||
|
sys.stdout.write(
|
||||||
|
f"\n[STANDARD] Archive status from {archivist_id}: {status_report}\n"
|
||||||
|
)
|
||||||
|
sys.stderr.write(
|
||||||
|
"[ALERT] System diagnostic: Communication channels verified\n"
|
||||||
|
)
|
||||||
|
sys.stdout.write("[STANDARD] Data transmission complete\n")
|
||||||
|
print("\nThree-channel communication test successful.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
communication_system()
|
||||||
21
04/ex3/ft_vault_security.py
Normal file
21
04/ex3/ft_vault_security.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
def vault_security_system() -> None:
|
||||||
|
print("=== CYBER ARCHIVES - VAULT SECURITY SYSTEM ===\n")
|
||||||
|
try:
|
||||||
|
print("Initiating secure vault access...")
|
||||||
|
with open("classified_data.txt", "r") as source_file, open(
|
||||||
|
"archive_data.txt", "w"
|
||||||
|
) as dest_file:
|
||||||
|
print("Vault connection established with failsafe protocols\n")
|
||||||
|
print("SECURE EXTRACTION:")
|
||||||
|
print(source_file.read())
|
||||||
|
print("\nSECURE PRESERVATION:")
|
||||||
|
dest_file.write("[CLASSIFIED] New security protocols archived")
|
||||||
|
print("[CLASSIFIED] New security protocols archived")
|
||||||
|
print("Vault automatically sealed upon completion")
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
print("\nAll vault operations completed with maximum security.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
vault_security_system()
|
||||||
31
04/ex4/ft_crisis_response.py
Normal file
31
04/ex4/ft_crisis_response.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
def file_error_tester() -> None:
|
||||||
|
print("=== CYBER ARCHIVES - CRISIS RESPONSE SYSTEM ===\n")
|
||||||
|
try:
|
||||||
|
print("CRISIS ALERT: Attempting access to 'lost_archive.txt'...")
|
||||||
|
with open("lost_archive.txt") as file:
|
||||||
|
print("STATUS: Normal operations resumed")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("RESPONSE: Archive not found in storage matrix")
|
||||||
|
print("STATUS: Crisis handled, system stable")
|
||||||
|
print()
|
||||||
|
try:
|
||||||
|
print("CRISIS ALERT: Attempting access to 'classified_vault.txt'...")
|
||||||
|
with open("/bin/zsh", "w") as file:
|
||||||
|
print("STATUS: Normal operations resumed")
|
||||||
|
except PermissionError:
|
||||||
|
print("RESPONSE: Security protocols deny access")
|
||||||
|
print("STATUS: Crisis handled, security maintained")
|
||||||
|
print()
|
||||||
|
try:
|
||||||
|
print("ROUTINE ACCESS: Attempting access to 'standard_archive.txt'...")
|
||||||
|
with open("standard_archive.txt") as file:
|
||||||
|
print(f"SUCCESS: Archive recovered - ``{file.read()}''")
|
||||||
|
print("STATUS: Normal operations resumed")
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
print("STATUS: Crisis handled, security maintained")
|
||||||
|
print("\nAll crisis scenarios handled successfully. Archives secure.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
file_error_tester()
|
||||||
Reference in New Issue
Block a user