Skip to content

Commit

Permalink
Moved a function that was only used by the test into the if __name__ …
Browse files Browse the repository at this point in the history
…== '__main__':
  • Loading branch information
cnobile2012 committed Dec 18, 2023
1 parent e3d9ab6 commit ad84874
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions sunrisesunset/sunrisesunset.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,26 @@ def __get_24_hour_local_time(self, decimal_time:float) -> datetime:
second=second, microsecond=micro)


def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
"""
The default lat and lon are for Knoxville, TN. The default zenith is
'official'.
"""
rs = SunriseSunset(date, lat=lat, lon=lon, zenith=zenith)
rise_time, set_time = rs.sun_rise_set
print(f"Using zenith: {zenith}")
print(f" Date/Time: {date}")
print(f" Sunrise: {rise_time}")
print(f" Sunset: {set_time}")
print(f" Is night: {rs.is_night()}\n")


if __name__ == '__main__':
import sys
import pytz
#from pprint import pprint
from geopy.geocoders import Nominatim
from timezonefinder import TimezoneFinder

def get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
"""
The default lat and lon are for Knoxville, TN. The default zenith is
'official'.
"""
rs = SunriseSunset(date, lat=lat, lon=lon, zenith=zenith)
rise_time, set_time = rs.sun_rise_set
print(f"Using zenith: {zenith}")
print(f" Date/Time: {date}")
print(f" Sunrise: {rise_time}")
print(f" Sunset: {set_time}")
print(f" Is night: {rs.is_night()}\n")

ret = 1
geolocator = Nominatim(user_agent='sunrisesunset')
address = input('Enter an address: ')
Expand Down Expand Up @@ -268,7 +267,7 @@ def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
print("Test zenith")

for zenith in zenith_keys:
__get_rise_set(dt, lat=lat, lon=lon, zenith=zenith)
get_rise_set(dt, lat=lat, lon=lon, zenith=zenith)

# Get sunrise sunset for every hour of the day using the
# default zenith.
Expand All @@ -280,7 +279,7 @@ def __get_rise_set(date, lat=35.9513, lon=-83.9142, zenith='official'):
for minute in range(0, 60, minutes):
date = dt.replace(hour=hour, minute=minute,
second=0, microsecond=0)
__get_rise_set(date, lat=lat, lon=lon)
get_rise_set(date, lat=lat, lon=lon)

ret = 0
else:
Expand Down

0 comments on commit ad84874

Please sign in to comment.