Skip to content

Commit 4680b38

Browse files
committed
refactoring - separated finding offers from printing them
1 parent 85b532a commit 4680b38

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

crawl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ back = sys.argv[4]
1010
flex = 0
1111
if len(sys.argv) == 6:
1212
flex = int(sys.argv[5])
13-
offersFinder.get_offers(orig_city=orig_city, dest_city=dest_city, leave=leave, back=back, forward_days=flex)
13+
offersFinder.find_offers(orig_city=orig_city, dest_city=dest_city, leave=leave, back=back, forward_days=flex)

expediacrawler/offersFinder.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
from expediacrawler.dateCalculator import calculate_new_dates
44

55

6+
def find_offers(orig_city, dest_city, leave, back, forward_days):
7+
all_offers = get_offers(orig_city, dest_city, leave, back, forward_days)
8+
for day in all_offers:
9+
print(day, ":")
10+
for offer in all_offers[day]:
11+
print(offer)
12+
13+
614
def get_offers(orig_city, dest_city, leave, back, forward_days):
715
all_offers = {}
816
day_offer = get_day_offers(orig_city, dest_city=dest_city, leave=leave, back=back)
@@ -12,11 +20,7 @@ def get_offers(orig_city, dest_city, leave, back, forward_days):
1220
out_str, return_str = calculate_new_dates(leave, back, i)
1321
day_offer = get_day_offers(orig_city, dest_city=dest_city, leave=out_str, back=return_str)
1422
all_offers[out_str + '-' + return_str] = day_offer[0:5]
15-
16-
for day in all_offers:
17-
print(day, ":")
18-
for offer in all_offers[day]:
19-
print(offer)
23+
return all_offers
2024

2125

2226
def get_day_offers(orig_city, dest_city, leave, back):

0 commit comments

Comments
 (0)