Simplify and clarify

This commit is contained in:
Chris 2022-03-09 22:09:05 -05:00
parent 729b179d43
commit 379c8033ad
2 changed files with 5 additions and 11 deletions

View File

@ -1,6 +1,6 @@
from weather.weather_apis import ( from weather.weather_apis import (
geocode_location, geocode_location,
geocode_ip_address, estimate_location,
get_weather_office, get_weather_office,
get_forecast get_forecast
) )
@ -12,10 +12,3 @@ def print_weather(location=None, metric=False, verbose=False):
When verbose is True, prints out a more detailed report. When verbose is True, prints out a more detailed report.
""" """
print("Not finished...") # YOUR CODE HERE! print("Not finished...") # YOUR CODE HERE!
# This is a clunky way to check whether this module was called directly with `python weather.py`,
# or whether it's being imported by another module. If the module is being called, then we
# should actually run `print_weather`. But if this module is just being imported, we probably don't
# want this module to call any functions. We'll leave that up whoever is doing the importing.
if __name__ == "__main__":
print_weather()

View File

@ -24,9 +24,10 @@ def geocode_location(location_string):
lat, lng = result.latlng lat, lng = result.latlng
return {'lat': lat, 'lng': lng} return {'lat': lat, 'lng': lng}
def geocode_ip_address(ip_address=None): def estimate_location(ip_address=None):
"""Translates an IP address into latitude and longitude coodrdinates. """Estimates a location based on the request's IP address, returning
When no IP address is provided, uses the user's current IP address. latitude and longitude coodrdinates. When no IP address is provided,
uses the user's current IP address.
>>> geocode_ip_address() >>> geocode_ip_address()
{'lat': 23.6585116, 'lng': -102.0077097} {'lat': 23.6585116, 'lng': -102.0077097}