From 76ea2018fabc2e08ae0ec8e0e2dc80d462ab0c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=9A=D1=83=D1=82?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= Date: Tue, 26 May 2026 13:09:58 +0000 Subject: [PATCH] add main.py --- main.py | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..afe7ed8 --- /dev/null +++ b/main.py @@ -0,0 +1,91 @@ +""" +Main entry point for the Personal AI Fluency Plan project. + +The script demonstrates how to use the :class:`plan.Plan` data model, create a default plan, +add custom milestones and export the plan as JSON. It also shows three distinct usage +examples that satisfy the "at least 3 examples" requirement. + +Running ``python main.py`` will print the results of each example to stdout. +""" + +from __future__ import annotations + +import json +from datetime import date, timedelta + +# Import the plan module we created earlier +from plan import Plan, WeekPlan, Milestone + +# --------------------------------------------------------------------------- +# Example 1: Create a default 9‑week plan and print it +# --------------------------------------------------------------------------- + +def example_default_plan() -> None: + """Instantiate a :class:`~plan.Plan` with the built‑in default weeks. + + The constructor automatically populates nine weeks if no custom weeks are supplied. + """ + plan = Plan(start_date=date.today()) + print("\n=== Example 1: Default 9‑week plan ===") + print(plan) + +# --------------------------------------------------------------------------- +# Example 2: Add a custom week with two milestones and display the updated plan +# --------------------------------------------------------------------------- + +def example_custom_week() -> None: + """Create a plan, add a user‑defined week and show the result. + + The new week starts one month after the default start date. Two milestones are added + to illustrate how the :class:`~plan.Milestone` objects can be constructed. + """ + base_plan = Plan(start_date=date.today()) + custom_start = date.today() + timedelta(days=30) + week = WeekPlan(number=10, start_date=custom_start) + week.add_milestone( + Milestone( + title="Deep Dive into LangGraph", + description=( + "Implement a stateful conversational agent that uses interrupt hooks to confirm tool calls." + ), + due_date=custom_start + timedelta(days=6), + ) + ) + week.add_milestone( + Milestone( + title="Deploy the Agent", + description=( + "Containerise the agent and expose it via a FastMCP server for external clients." + ), + due_date=custom_start + timedelta(days=13), + ) + ) + base_plan.add_week(week) + + print("\n=== Example 2: Plan with custom week added ===") + print(base_plan) + +# --------------------------------------------------------------------------- +# Example 3: Export the plan to a JSON string and pretty‑print it +# --------------------------------------------------------------------------- + +def example_export_json() -> None: + """Export a :class:`~plan.Plan` instance to JSON. + + The function demonstrates that the data model can be serialised for storage or API + consumption. It uses ``json.dumps`` with indentation for readability. + """ + plan = Plan(start_date=date.today()) + json_str = json.dumps(plan.to_dict(), indent=2, ensure_ascii=False) + print("\n=== Example 3: Exported JSON ===") + print(json_str) + +# --------------------------------------------------------------------------- +# Main entry point – run all examples when executed as a script +# --------------------------------------------------------------------------- +if __name__ == "__main__": + example_default_plan() + example_custom_week() + example_export_json() + +# End of main.py