From 222b212162d07405f39ae5ed468da4a3d5515c7c Mon Sep 17 00:00:00 2001 From: David GAILLETON Date: Sun, 15 Feb 2026 13:33:04 +0100 Subject: [PATCH] module 06 --- 04/ex0/ft_ancient_text.py | 2 ++ 04/ex2/ft_stream_management.py | 4 ++-- 06/ft_circular_curse.py | 32 +++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/04/ex0/ft_ancient_text.py b/04/ex0/ft_ancient_text.py index 24a0312..89df7ba 100644 --- a/04/ex0/ft_ancient_text.py +++ b/04/ex0/ft_ancient_text.py @@ -9,6 +9,8 @@ def read_ancient_text() -> None: print("\nData recovery complete. Storage unit disconnected.") except FileNotFoundError: print("ERROR: Storage vault not found.") + except Exception as err: + print(err) if __name__ == "__main__": diff --git a/04/ex2/ft_stream_management.py b/04/ex2/ft_stream_management.py index 3f9d33a..cee6cf2 100644 --- a/04/ex2/ft_stream_management.py +++ b/04/ex2/ft_stream_management.py @@ -2,8 +2,8 @@ import sys def communication_system() -> None: - print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===") - sys.stdout.write("\nInput Stream active. Enter archivist ID: ") + print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===\n") + sys.stdout.write("Input Stream active. Enter archivist ID: ") archivist_id = input() sys.stdout.write("Input Stream active. Enter status report: ") status_report = input() diff --git a/06/ft_circular_curse.py b/06/ft_circular_curse.py index adcb2da..80035f1 100644 --- a/06/ft_circular_curse.py +++ b/06/ft_circular_curse.py @@ -1,13 +1,43 @@ def ingredients_validation() -> None: - import alchemy.grimoire + from alchemy.grimoire.validator import validate_ingredients print( f'validate_ingredients("fire air"): {validate_ingredients("fire air")}' ) + print( + f'validate_ingredients("dragon scale"): {validate_ingredients("dragon scale")}' + ) + + +def spell_recording_test() -> None: + from alchemy.grimoire.spellbook import record_spell + + print( + f'record_spell("Fireball", "fire air"): {record_spell("Fireball", "fire air")}' + ) + print( + f'record_spell("Dark Magic", "shadow"): {record_spell("Dark Magic", "shadow")}' + ) + + +def late_import_test() -> None: + from alchemy.grimoire.spellbook import record_spell + + print( + f'record_spell("Lightning", "air"): {record_spell("Lightning", "air")}' + ) def main() -> None: + print("=== Circular Curse Breaking ===\n") + print("Testing ingredient validation:") ingredients_validation() + print("\nTesting spell recording with validation:") + spell_recording_test() + print("\nTesting late import technique:") + late_import_test() + print("\nCircular dependency curse avoided using late imports!") + print("All spells processed safely!") if __name__ == "__main__":