From b1eb1dface7a6ed441e3dbd44bc7b5139e1cfce6 Mon Sep 17 00:00:00 2001 From: AaronToh Date: Sun, 26 Oct 2025 21:38:04 +0800 Subject: [PATCH 1/2] Implement hands on hp-view-graph --- hands_on/view_graph.py | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 hands_on/view_graph.py diff --git a/hands_on/view_graph.py b/hands_on/view_graph.py new file mode 100644 index 0000000..feb0528 --- /dev/null +++ b/hands_on/view_graph.py @@ -0,0 +1,44 @@ +import os +from typing import Any + +from exercise_utils.file import create_or_update_file, append_to_file +from exercise_utils.git import add, init, commit + +__requires_git__ = True +__requires_github__ = False + + +def download(verbose: bool = False) -> None: + """Create a sandbox repository for the hp-view-graph hands-on. + + The sandbox layout matches the instructions provided in the exercise. + """ + os.makedirs("things", exist_ok=True) + os.chdir("things") + + # Initialize repository + init(verbose) + + # Initial fruits file and commit + create_or_update_file( + "fruits.txt", + """ + apples + bananas + cherries + dragon fruits + """, + ) + add(["fruits.txt"], verbose) + commit("Add fruits.txt", verbose) + + # Append figs, stage and commit + append_to_file("fruits.txt", "figs\n") + add(["fruits.txt"], verbose) + commit("Insert figs into fruits.txt", verbose) + + # Add colours and shapes together and commit + create_or_update_file("colours.txt", "a file for colours\n") + create_or_update_file("shapes.txt", "a file for shapes\n") + add(["colours.txt", "shapes.txt"], verbose) + commit("Add colours.txt, shapes.txt", verbose) From 165c0ebb77df37ca3ed01399f161d03a4b9b1166 Mon Sep 17 00:00:00 2001 From: AaronToh Date: Sun, 26 Oct 2025 22:50:49 +0800 Subject: [PATCH 2/2] Make changes --- hands_on/view_graph.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hands_on/view_graph.py b/hands_on/view_graph.py index feb0528..2dda858 100644 --- a/hands_on/view_graph.py +++ b/hands_on/view_graph.py @@ -1,5 +1,4 @@ import os -from typing import Any from exercise_utils.file import create_or_update_file, append_to_file from exercise_utils.git import add, init, commit @@ -9,11 +8,7 @@ def download(verbose: bool = False) -> None: - """Create a sandbox repository for the hp-view-graph hands-on. - - The sandbox layout matches the instructions provided in the exercise. - """ - os.makedirs("things", exist_ok=True) + os.makedirs("things") os.chdir("things") # Initialize repository