code cleanup

This commit is contained in:
Jason Ji 2017-09-24 11:59:57 -07:00
parent c23fd43b51
commit 0c4a3abf23

View File

@ -23,10 +23,7 @@ def get_weather(message):
""" """
get_weather(location) get_weather(location)
Returns the weather forecast for the selected location. Uses PythonOWM to Returns the weather forecast for the selected location. Uses PythonOWM.
make life super easy.
TODO: Replace basic code block with nice looking, bold text w/ emojis
""" """
try: try:
forecaster = openweathermap.three_hours_forecast(message) forecaster = openweathermap.three_hours_forecast(message)
@ -36,12 +33,12 @@ def get_weather(message):
location = forecast.get_location().get_name() location = forecast.get_location().get_name()
indicator = int(reg.get_reference_time(timeformat='iso')[11:13]) // 3 indicator = int(reg.get_reference_time(timeformat='iso')[11:13]) // 3
curr_stat = '{}{}{}{}{}{}{}'.format(' \n***Status in ', location, ':*** *', curr_stat = ' \n***Status in {}:*** *{}* {}\n'.format(
reg.get_detailed_status().title(), '*', location,
emojis.get(reg.get_detailed_status()), '\n') reg.get_detailed_status().title(),
curr_temp = '{}{}{}'.format('**Current Temperature:** *', emojis[reg.get_detailed_status()])
str(reg.get_temperature('fahrenheit').get('temp')), curr_temp = '**Currently:** *{}F*\n\n__**3 day forecast:**__\n'.format(
'F*\n\n__**3 day forecast:**__\n') str(reg.get_temperature('fahrenheit').get('temp')))
forecast_str = '{}{}'.format(curr_stat, curr_temp) forecast_str = '{}{}'.format(curr_stat, curr_temp)
ind = 0 ind = 0
@ -62,12 +59,15 @@ def get_weather(message):
if low > l: if low > l:
low = l low = l
day = '{}{}{}'.format('***', days_from_ind.get(ind), '***\n') day = '***{}***\n'.format(
weather_stat = '{}{}{}{}{}'.format('**Status:** *', days_from_ind.get(ind))
weather_stat = '**Status:** *{}* {}\n'.format(
forecast.get(i).get_detailed_status().title(), forecast.get(i).get_detailed_status().title(),
'* ', emojis.get(forecast.get(i).get_detailed_status()), '\n') emojis[forecast.get(i).get_detailed_status()])
high_temp = '{}{}{}'.format('**High:** *', str(high), 'F*\n') high_temp = '**High:** *{}F*\n'.format(
low_temp = '{}{}{}'.format('**Low:** *', str(low), 'F*\n\n') str(high))
low_temp = '**Low:** *{}F*\n\n'.format(
str(low))
forecast_str = '{}{}{}{}{}'.format( forecast_str = '{}{}{}{}{}'.format(
forecast_str, day, weather_stat, high_temp, low_temp) forecast_str, day, weather_stat, high_temp, low_temp)
ind += 1 ind += 1