From 7234f9bd04e0d320f45f3ee5aa1634bcb7b33b4d Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Wed, 6 Feb 2019 06:51:26 -0800 Subject: [PATCH] Refactored almanac.py for Python 3 --- bin/weewx/almanac.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/weewx/almanac.py b/bin/weewx/almanac.py index 2dcce06e..65281934 100644 --- a/bin/weewx/almanac.py +++ b/bin/weewx/almanac.py @@ -8,7 +8,6 @@ This module can optionally use PyEphem, which offers high quality astronomical calculations. See http://rhodesmill.org/pyephem. """ -from __future__ import print_function import time import sys import math @@ -83,23 +82,23 @@ class Almanac(object): Fullness of the moon (more precise) is 1.70% Test backwards compatibility with attributes 'sunrise' and 'sunset' - >>> print("Sunrise, sunset:", almanac.sunrise, almanac.sunset) + >>> print("Sunrise, sunset: %s %s" % (almanac.sunrise, almanac.sunset)) Sunrise, sunset: 06:56 19:30 Get sunrise, sun transit, and sunset using the new 'ephem' syntax: - >>> print("Sunrise, sun transit, sunset:", almanac.sun.rise, almanac.sun.transit, almanac.sun.set) + >>> print("Sunrise, sun transit, sunset: %s %s %s" % (almanac.sun.rise, almanac.sun.transit, almanac.sun.set)) Sunrise, sun transit, sunset: 06:56 13:13 19:30 Do the same with the moon: - >>> print("Moon rise, transit, set:", almanac.moon.rise, almanac.moon.transit, almanac.moon.set) + >>> print("Moon rise, transit, set: %s %s %s" % (almanac.moon.rise, almanac.moon.transit, almanac.moon.set)) Moon rise, transit, set: 06:59 14:01 21:20 And Mars - >>> print("Mars rise, transit, set:", almanac.mars.rise, almanac.mars.transit, almanac.mars.set) + >>> print("Mars rise, transit, set: %s %s %s" % (almanac.mars.rise, almanac.mars.transit, almanac.mars.set)) Mars rise, transit, set: 06:08 11:34 17:00 Finally, try a star - >>> print("Rigel rise, transit, set:", almanac.rigel.rise, almanac.rigel.transit, almanac.rigel.set) + >>> print("Rigel rise, transit, set: %s %s %s" % (almanac.rigel.rise, almanac.rigel.transit, almanac.rigel.set)) Rigel rise, transit, set: 12:32 18:00 23:28 Exercise sidereal time