Skip to content

Commit

Permalink
add bs4 to reqs, add placeholder for country mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
kronicka committed Dec 29, 2018
1 parent 270544c commit a4b77cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
23 changes: 15 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# I'm leaving this stuff in until I refactor it into a more generic function/class
def calculate_days(*dob: int) -> int:
"""
Calculate the number of days left to live based on date of birth
NOTE: This function was a mistake, but just in case you want to know the number of days I'm leaving it in
Calculate the number of days left to live based on date of birth
NOTE: This function was a mistake, but just in case you want to know the number of days I'm leaving it in
"""
days_lived = abs(date.today() - date(*dob)).days
days_left = general_life_expectancy_days - days_lived
Expand All @@ -39,7 +39,7 @@ def calculate_days(*dob: int) -> int:
# Actually relevant code starts here
def input_dob() -> Tuple[int, int, int]:
"""
Input and validate date of birth
Input and validate date of birth
"""
dob = input('Enter your date of birth (YYYY-MM-DD):\n')
dob = parse(dob)
Expand All @@ -48,7 +48,7 @@ def input_dob() -> Tuple[int, int, int]:

def input_sex() -> bool:
"""
Input and validate biological sex
Input and validate biological sex
"""
while True:
sex = input('Enter your biological sex (m/f):\n')
Expand All @@ -62,7 +62,7 @@ def input_sex() -> bool:

def input_country() -> str:
"""
Input a valid country or a 2-letter country alias (e.g., "Germany" = "DE")
Input a valid country or a 2-letter country alias (e.g., "Germany" = "DE")
"""
while True:
country = input('Enter your country (full name or 2-letter alias):\n')
Expand All @@ -74,9 +74,16 @@ def input_country() -> str:
print('Please enter a valid country name.')


def calculate_weeks(sex: bool, *dob: int) -> int:
def map_country(country: str) -> int:
"""
Calculate the number of weeks left to live based on date of birth
Return the average life expectancy based on the country
"""
pass


def calculate_weeks(sex: bool, country_index: int, *dob: int) -> int:
"""
Calculate the number of weeks left to live based on date of birth
"""
weeks_lived = abs(date.today() - date(*dob)).days / 7
weeks_left = (female_life_expectancy_weeks if sex else male_life_expectancy_weeks) - weeks_lived
Expand All @@ -87,7 +94,7 @@ def calculate_weeks(sex: bool, *dob: int) -> int:

def generate_calendar(units: int, unit_type: str = None):
"""
Generate a calendar based on the number of weeks
Generate a calendar based on the number of weeks
"""
square_path = 'img/square.jpg'
background_path = 'img/background.png'
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bs4
Pillow>=5.3.0
python-dateutil
pycountry>=18.12.8
5 changes: 5 additions & 0 deletions scraper.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Scraper of the The World Bank most recent life expectancy stats
# for when the prediction based on the country is made
from bs4 import BeautifulSoup

soup = BeautifulSoup('<html><body><b>Hi</b></body></html>', 'html.parser')

print(soup.body)

0 comments on commit a4b77cd

Please sign in to comment.