From 311881ceb16012b43b9b3b67471c231936bd2c86 Mon Sep 17 00:00:00 2001 From: kairos Date: Wed, 8 Jan 2025 07:55:21 +0000 Subject: [PATCH] Delete examples directory --- examples/example_chained_assignment.py | 16 ------------ examples/example_combined_access.py | 30 ---------------------- examples/example_error_handling.py | 27 -------------------- examples/example_logging.py | 27 -------------------- examples/example_method_interception.py | 18 -------------- examples/example_nested_structures.py | 33 ------------------------- examples/example_path_based_access.py | 23 ----------------- examples/example_safe_access.py | 17 ------------- 8 files changed, 191 deletions(-) delete mode 100644 examples/example_chained_assignment.py delete mode 100644 examples/example_combined_access.py delete mode 100644 examples/example_error_handling.py delete mode 100644 examples/example_logging.py delete mode 100644 examples/example_method_interception.py delete mode 100644 examples/example_nested_structures.py delete mode 100644 examples/example_path_based_access.py delete mode 100644 examples/example_safe_access.py diff --git a/examples/example_chained_assignment.py b/examples/example_chained_assignment.py deleted file mode 100644 index 638c33d..0000000 --- a/examples/example_chained_assignment.py +++ /dev/null @@ -1,16 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_chained_assignment(): - objectron = Objectron() - a = objectron.transform({}) - - # Assigning a.b.c.d.e.f = 3 - a.b.c.d.e.f = 3 - - print(a) # Output: DictProxy({'b': {'c': {'d': {'e': {'f': 3}}}}}}) - print(a.b.c.d.e.f) # Output: 3 - - -if __name__ == "__main__": - example_chained_assignment() diff --git a/examples/example_combined_access.py b/examples/example_combined_access.py deleted file mode 100644 index 3f3fb3e..0000000 --- a/examples/example_combined_access.py +++ /dev/null @@ -1,30 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_combined_access(): - objectron = Objectron() - a = objectron.transform({}) - - # Assign using attribute chaining - a.b.c.d.e.f = 3 - print(a) # Output: DictProxy({'b': {'c': {'d': {'e': {'f': 3}}}}}}) - - # Assign using path string - a["b.c.d.e.g"] = 4 - print(a) # Output: DictProxy({'b': {'c': {'d': {'e': {'f': 3, 'g': 4}}}}}}) - - # Access using both methods - print(a.b.c.d.e.f) # Output: 3 - print(a["b.c.d.e.g"]) # Output: 4 - - # Safe access that doesn't alter the structure - try: - print(a.b.c.x) - except AttributeError as e: - print(f"Caught an AttributeError: {e}") - - print(a) # Output remains unchanged - - -if __name__ == "__main__": - example_combined_access() diff --git a/examples/example_error_handling.py b/examples/example_error_handling.py deleted file mode 100644 index 0abad47..0000000 --- a/examples/example_error_handling.py +++ /dev/null @@ -1,27 +0,0 @@ -from Objectron.exceptions import TransformationError -from Objectron.objectron import Objectron - - -def example_error_handling(): - objectron = Objectron() - a = objectron.transform({"numbers": [1, 2, 3]}) - - # Attempt to access an invalid path - try: - print(a["numbers.10"]) # Index out of range - except (KeyError, IndexError, TypeError) as e: - print(f"Error: {e}") - - # Attempt to set a value with an invalid type - try: - a["numbers"].append("four") # Should work, but if type is restricted, may raise - except TransformationError as e: - print(f"Transformation Error: {e}") - - # Properly setting a value - a["numbers"].append(4) - print(a["numbers"]) # Output: [1, 2, 3, 4] - - -if __name__ == "__main__": - example_error_handling() diff --git a/examples/example_logging.py b/examples/example_logging.py deleted file mode 100644 index e358020..0000000 --- a/examples/example_logging.py +++ /dev/null @@ -1,27 +0,0 @@ -from Objectron.objectron import Objectron -from Objectron.wrappers import method_wrapper - - -class Calculator: - @method_wrapper - def add(self, a: int, b: int) -> int: - return a + b - - @method_wrapper - def multiply(self, a, b): - return a * b - - -def example_logging(): - objectron = Objectron() - calc = objectron.transform(Calculator()) - - result_add = calc.add(5, 7) - print(f"Addition Result: {result_add}") # Output: 12 - - result_mul = calc.multiply(3, 4) - print(f"Multiplication Result: {result_mul}") # Output: 12 - - -if __name__ == "__main__": - example_logging() diff --git a/examples/example_method_interception.py b/examples/example_method_interception.py deleted file mode 100644 index bbfc971..0000000 --- a/examples/example_method_interception.py +++ /dev/null @@ -1,18 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_method_interception(): - objectron = Objectron() - a = objectron.transform({"list": [1, 2, 3]}) - - # Append using path string - a["list"].append(4) - # Output: - # INFO:__main__:Executing method: append - # INFO:__main__:Method append executed successfully. - - print(a["list"]) # Output: [1, 2, 3, 4] - - -if __name__ == "__main__": - example_method_interception() diff --git a/examples/example_nested_structures.py b/examples/example_nested_structures.py deleted file mode 100644 index 22051db..0000000 --- a/examples/example_nested_structures.py +++ /dev/null @@ -1,33 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_nested_structures() -> None: - objectron = Objectron() - data = objectron.transform( - { - "users": [ - {"name": "Alice", "details": {"age": 30, "email": "alice@example.com"}}, - {"name": "Bob", "details": {"age": 25, "email": "bob@example.com"}}, - ] - } - ) - - # Access using attribute chaining - print(data.users[0].name) # Output: Alice - print(data.users[1].details.email) # Output: bob@example.com - - # Modify using path-based access - data["users.0.details.age"] = 31 - print(data.users[0].details.age) # Output: 31 - - # Add a new user - new_user = { - "name": "Charlie", - "details": {"age": 28, "email": "charlie@example.com"}, - } - data.users.append(new_user) - print(data.users[2].name) # Output: Charlie - - -if __name__ == "__main__": - example_nested_structures() diff --git a/examples/example_path_based_access.py b/examples/example_path_based_access.py deleted file mode 100644 index 369e1b1..0000000 --- a/examples/example_path_based_access.py +++ /dev/null @@ -1,23 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_path_based_access() -> None: - objectron = Objectron() - a = objectron.transform({}) - - # Assign using path string - a["x.y.z"] = 10 - print(a) # Output: DictProxy({'x': {'y': {'z': 10}}}}) - - # Access using path string - value = a["x.y.z"] - print(value) # Output: 10 - - # Modify using path string - a["x.y.z"] += 5 - print(a["x.y.z"]) # Output: 15 - print(a) # Output: DictProxy({'x': {'y': {'z': 15}}}}) - - -if __name__ == "__main__": - example_path_based_access() diff --git a/examples/example_safe_access.py b/examples/example_safe_access.py deleted file mode 100644 index ec3a113..0000000 --- a/examples/example_safe_access.py +++ /dev/null @@ -1,17 +0,0 @@ -from Objectron.objectron import Objectron - - -def example_safe_access(): - objectron = Objectron() - a = objectron.transform({}) - - try: - print(a.b.c.d.e) - except AttributeError as e: - print(f"Caught an AttributeError: {e}") # Expected: Caught an AttributeError - - print(a) # Output remains unchanged: DictProxy({}) - - -if __name__ == "__main__": - example_safe_access()