-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.py
58 lines (51 loc) · 2.08 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from beautiful_soup_cleaner import *
from component_evaluator import *
from helpful_methods import *
print("Welcome to the PCPartPicker link analyzer!")
print("This program takes in the following values only:")
print_max_five(relevant_components)
print("and then computes the budget of those values, then lets")
print("you know where you need to make changes.")
html_file_raw = input("Enter a link:\n")
html_file = clean_html(html_file_raw)
soup = get_soup(html_file)
prices_per_component = get_list(soup)
total_price = price_total(prices_per_component)
"""
TODO (else statement):
figure out what components are missing and prompt the user for theoretical values
"""
if is_all_components_present(prices_per_component):
print("All of the necessary components have been accounted, " +
"for a total of ", end = '')
print("${:.2f}.".format(total_price))
budget_chosen = False
budget_found = False
print("Is that the correct budget for these components?")
print("Enter [y] for yes or [n] for no.", end = (''))
while(not budget_chosen or not budget_found):
is_budget = input().upper()
if is_budget == "Y":
budget_chosen = True
budget = total_price
budget_found = True
elif is_budget == "N":
budget_chosen = True
print("No problem. Please type in your budget.", end = (''))
while not budget_found:
budget_input = input()
try:
budget_input = round(float(budget_input), 2)
budget = budget_input
budget_found = True
except (TypeError, ValueError):
print("Sorry, invalid input. Please enter a float.", end = (''))
else:
print("Sorry, invalid input. Select [y] or [n].", end = '')
else:
print("Sorry, this program requires all of these components to have a " +
"price:")
print_max_five(relevant_components)
print("Come back when you have those numbers filled out!")
raise SystemExit()
evaluate_price(prices_per_component, budget)