Skip to content

Commit

Permalink
add input_country function, add requirements file, add a dummy file f…
Browse files Browse the repository at this point in the history
…or a future scraper
  • Loading branch information
kronicka committed Dec 25, 2018
1 parent c6af1bc commit 560ee87
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dateutil.parser import parse
from PIL import Image
from typing import Tuple
from pycountry import countries

# TODO: scale square pics based on the number of weeks
# TODO: merge functionality for calculating days, weeks (and, maybe, months and years)
Expand Down Expand Up @@ -58,6 +59,20 @@ def input_sex() -> bool:
continue


def input_country() -> str:
"""
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')
country_names = [country.name for country in countries]
country_codes = [country.alpha_2 for country in countries]
if country.capitalize() in country_names or country.upper() in country_codes:
return country
else:
print('Please enter a valid country name.')


def calculate_weeks(sex: bool, *dob: int) -> int:
"""
Calculate the number of weeks left to live based on date of birth
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pillow>=5.3.0
python-dateutil
pycountry>=18.12.8
2 changes: 2 additions & 0 deletions scraper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scraper of the The World Bank most recent life expectancy stats
# for when the prediction based on the country is made

0 comments on commit 560ee87

Please sign in to comment.