Skip to content

Commit f836acd

Browse files
Chore: Added docstring for validation function & minor editing.
1 parent bf66474 commit f836acd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Travel Itinerary Planner/src/manage_itineraries.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def add_itinerary(itinerary_list, name, location, summary, start_date, end_date, flights, attractions):
11-
"""
11+
'''
1212
Add a new itinerary to the list of itineraries.
1313
1414
Args:
@@ -23,12 +23,10 @@ def add_itinerary(itinerary_list, name, location, summary, start_date, end_date,
2323
Returns:
2424
bool: True if Itinerary is added without issue, otherwise False.
2525
26-
Raises:
27-
ValueError: If the start or end date is not in the correct format.
28-
2926
Side Effects:
3027
- Saves the updated itinerary list to a file using `update_itinerary`.
31-
"""
28+
'''
29+
3230
# Prevent duplicate itineraries
3331
if any(trip.name == name for trip in itinerary_list):
3432
print("Error: A trip with this name already exists!")
@@ -70,7 +68,17 @@ def export_itinerary(itinerary, chosen_itinerary):
7068
# Validation functions
7169

7270
def validate_dates(start_date, end_date, flights):
73-
# Validate dates given for start date, end date and flight datetimes
71+
'''
72+
Validate dates given for start date, end date and flight datetimes
73+
74+
Raises:
75+
ValueError: If the start or end date is not in the correct format.
76+
77+
:param start_date (DD-MM-YYYY): Itinerary start date.
78+
:param end_date (DD-MM-YYYY): Itinerary start date.
79+
:param flights (nested dict): Nested dictionary containing flight information. This function will be testing the departure_date and arrival_date items.
80+
'''
81+
7482
try:
7583
datetime.strptime(start_date, "%d-%m-%Y")
7684
except ValueError:

0 commit comments

Comments
 (0)