Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKshitij Kumar <kshitijakumar@gmail.com>2013-01-12 17:32:35 (GMT)
committer Kshitij Kumar <kshitijakumar@gmail.com>2013-01-12 17:32:35 (GMT)
commit13b2d40baffe4aeac3eea14fea1dd732c341dea6 (patch)
tree0606b73c91b2c46451fc81b4064d2773e31fd79f
parentd6ef5f78e9412819658289d1df0d753d0c4ccc63 (diff)
fixed indentation
-rwxr-xr-xmoon.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/moon.py b/moon.py
index 56eb04e..66ad0c3 100755
--- a/moon.py
+++ b/moon.py
@@ -62,7 +62,7 @@ class MoonActivity(activity.Activity):
activity.Activity.__init__(self, handle)
self._name = handle
self.set_title(_("Moon"))
-
+
# Defaults (Resume priority, persistent file secondary, fall-back hardcoded)
if handle.object_id == None:
print "Launched from home."
@@ -104,7 +104,7 @@ class MoonActivity(activity.Activity):
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
-
+
# Items we don't have to do every redraw
#Gdk.Color = Gdk.Color_get_system()
self.black_alloc_color = Gdk.color_parse('black')
@@ -205,26 +205,26 @@ class MoonActivity(activity.Activity):
"""Read state from datastore.
"""
self.read_and_parse_prefs(file_path)
-
+
def write_file(self, file_path):
"""Write state to journal datastore and to persistent file system.
"""
self.activity_state['hemisphereView'] = self.hemisphere_view
self.activity_state['showGrid'] = self.show_grid
serialised_data = json.dumps(self.activity_state)
-
+
to_journal = file(file_path, 'w')
try:
to_journal.write(serialised_data)
finally:
to_journal.close()
-
+
to_persistent_fs = file(os.environ['SUGAR_ACTIVITY_ROOT'] + '/data/defaults', 'w')
try:
to_persistent_fs.write(serialised_data)
finally:
to_persistent_fs.close()
-
+
def toggle_grid_clicked(self, widget):
"""Respond to toolbar button to hide/show grid lines.
"""
@@ -286,22 +286,22 @@ class MoonActivity(activity.Activity):
self.image_pixbuf = Gdk.pixbuf_get_from_surface(cairo_surface, 0, 0, IMAGE_SIZE, IMAGE_SIZE)
#Write pixbuf to Gtk.Image
self.image.set_from_pixbuf(self.image_pixbuf)
-
+
#self.image_pixbuf = cairo_surface(None, IMAGE_SIZE, IMAGE_SIZE)
#self.gc = self.image_pixbuf.new_gc(foreground=self.black_alloc_color)
#self.image.set_from_pixbuf(self.image_pixbuf, None)
# Erase last Moon rendering
#self.image_pixbuf.draw_rectangle(self.gc, True, 0, 0, IMAGE_SIZE, IMAGE_SIZE)
-
+
# Create a 1bit shadow mask
mask_pixbuf = cairo_surface(self.image_pixbuf, IMAGE_SIZE, IMAGE_SIZE, depth=1)
kgc = mask_pixbuf.new_gc(foreground=self.black_alloc_color)
wgc = mask_pixbuf.new_gc(foreground=self.white_alloc_color)
mask_pixbuf.draw_rectangle(kgc, True, 0, 0, IMAGE_SIZE, IMAGE_SIZE)
if self.data_model.phase_of_moon <= .25:
-
-
+
+
# New Moon to First Quarter
phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
arc_scale = int(IMAGE_SIZE * (1 - (phase_shadow_adjust * 4)))
@@ -326,10 +326,10 @@ class MoonActivity(activity.Activity):
mask_pixbuf.draw_rectangle(wgc, True, 0, 0, HALF_SIZE, IMAGE_SIZE)
mask_pixbuf.draw_arc(kgc, True, HALF_SIZE - int(arc_scale / 2), 0, arc_scale, IMAGE_SIZE, 5760, 11520)
maskgc = self.image_pixbuf.new_gc(clip_mask=mask_pixbuf)
-
+
# Modified image based on public domain photo by John MacCooey
moon_pixbuf = self.moon_stamp.scale_simple(IMAGE_SIZE, IMAGE_SIZE,
- GdkPixbuf.InterpType.BILINEAR)
+ GdkPixbuf.InterpType.BILINEAR)
# Composite bright Moon image and semi-transparant Moon for shadow detail
dark_pixbuf = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, True, 8, IMAGE_SIZE, IMAGE_SIZE)
@@ -378,7 +378,7 @@ class MoonActivity(activity.Activity):
# Update the Moon image in another 5min
self.update_moon_image_timeout = GObject.timeout_add(300000, self.update_moon_image_view)
-
+
# Stop this timer running
return False
@@ -457,24 +457,24 @@ class MoonActivity(activity.Activity):
class DataModel():
"""Moon phase data model and various utility methods.
"""
-
+
def __init__(self):
"""Init hard coded, tupules for New, First Quarter, Full Last Quarter Moon UTC data.
-
+
2008 to 2018 data from http://sunearth.gsfc.nasa.gov/eclipse/phase/phasecat.html
algorithms used in predicting the phases of the Moon and eclipses are based
on Jean Meeus' Astronomical Algorithms (Willmann-Bell, Inc., 1998). All
calculations are by Fred Espenak, and he assumes full responsibility for
their accuracy. Permission is freely granted to reproduce this data when
accompanied by an acknowledgment.
-
+
Data is all UTC and in YYYY-MM-DD HH:MM format, with New and Full Moon
arrays with an extra end character for eclipse types T=Total (Solar),
A=Annular (Solar), H=Hybrid (Solar Annular/Total), P=Partial (Solar),
t=Total (Lunar Umbral), p=Partial (Lunar Umbral), n=Penumbral (Lunar),
_=none.
"""
-
+
self.date_format = "%Y-%m-%d %H:%M"
self.new_moon_array = ("2008-01-08 11:37_", "2008-02-07 03:44A", "2008-03-07 17:14_", "2008-04-06 03:55_", "2008-05-05 12:18_", "2008-06-03 19:23_", "2008-07-03 02:19_", "2008-08-01 10:13T", "2008-08-30 19:58_", "2008-09-29 08:12_", "2008-10-28 23:14_", "2008-11-27 16:55_", "2008-12-27 12:23_", "2009-01-26 07:55A", "2009-02-25 01:35_", "2009-03-26 16:06_", "2009-04-25 03:23_", "2009-05-24 12:11_", "2009-06-22 19:35_", "2009-07-22 02:35T", "2009-08-20 10:01_", "2009-09-18 18:44_", "2009-10-18 05:33_", "2009-11-16 19:14_", "2009-12-16 12:02_", "2010-01-15 07:11A", "2010-02-14 02:51_", "2010-03-15 21:01_", "2010-04-14 12:29_", "2010-05-14 01:04_", "2010-06-12 11:15_", "2010-07-11 19:40T", "2010-08-10 03:08_", "2010-09-08 10:30_", "2010-10-07 18:44_", "2010-11-06 04:52_", "2010-12-05 17:36_", "2011-01-04 09:03P", "2011-02-03 02:31_", "2011-03-04 20:46_", "2011-04-03 14:32_", "2011-05-03 06:51_", "2011-06-01 21:03P", "2011-07-01 08:54P", "2011-07-30 18:40_", "2011-08-29 03:04_", "2011-09-27 11:09_", "2011-10-26 19:56_", "2011-11-25 06:10P", "2011-12-24 18:06_", "2012-01-23 07:39_", "2012-02-21 22:35_", "2012-03-22 14:37_", "2012-04-21 07:18_", "2012-05-20 23:47A", "2012-06-19 15:02_", "2012-07-19 04:24_", "2012-08-17 15:54_", "2012-09-16 02:11_", "2012-10-15 12:02_", "2012-11-13 22:08T", "2012-12-13 08:42_", "2013-01-11 19:44_", "2013-02-10 07:20_", "2013-03-11 19:51_", "2013-04-10 09:35_", "2013-05-10 00:29A", "2013-06-08 15:56_", "2013-07-08 07:14_", "2013-08-06 21:51_", "2013-09-05 11:36_", "2013-10-05 00:35_", "2013-11-03 12:50H", "2013-12-03 00:22_", "2014-01-01 11:14_", "2014-01-30 21:39_", "2014-03-01 08:00_", "2014-03-30 18:45_", "2014-04-29 06:14A", "2014-05-28 18:40_", "2014-06-27 08:09_", "2014-07-26 22:42_", "2014-08-25 14:13_", "2014-09-24 06:14_", "2014-10-23 21:57P", "2014-11-22 12:32_", "2014-12-22 01:36_", "2015-01-20 13:14_", "2015-02-18 23:47_", "2015-03-20 09:36T", "2015-04-18 18:57_", "2015-05-18 04:13_", "2015-06-16 14:05_", "2015-07-16 01:24_", "2015-08-14 14:54_", "2015-09-13 06:41P", "2015-10-13 00:06_", "2015-11-11 17:47_", "2015-12-11 10:29_", "2016-01-10 01:30_", "2016-02-08 14:39_", "2016-03-09 01:54T", "2016-04-07 11:24_", "2016-05-06 19:30_", "2016-06-05 03:00_", "2016-07-04 11:01_", "2016-08-02 20:45_", "2016-09-01 09:03A", "2016-10-01 00:12_", "2016-10-30 17:38_", "2016-11-29 12:18_", "2016-12-29 06:53_", "2017-01-28 00:07_", "2017-02-26 14:58A", "2017-03-28 02:57_", "2017-04-26 12:16_", "2017-05-25 19:44_", "2017-06-24 02:31_", "2017-07-23 09:46_", "2017-08-21 18:30T", "2017-09-20 05:30_", "2017-10-19 19:12_", "2017-11-18 11:42_", "2017-12-18 06:31_", "2018-01-17 02:17_", "2018-02-15 21:05P", "2018-03-17 13:12_", "2018-04-16 01:57_", "2018-05-15 11:48_", "2018-06-13 19:43_", "2018-07-13 02:48P", "2018-08-11 09:58P", "2018-09-09 18:01_", "2018-10-09 03:47_", "2018-11-07 16:02_", "2018-12-07 07:20_")
self.full_moon_array = ("2008-01-22 13:35_", "2008-02-21 03:31t", "2008-03-21 18:40_", "2008-04-20 10:25_", "2008-05-20 02:11_", "2008-06-18 17:30_", "2008-07-18 07:59_", "2008-08-16 21:16p", "2008-09-15 09:13_", "2008-10-14 20:03_", "2008-11-13 06:17_", "2008-12-12 16:37_", "2009-01-11 03:27_", "2009-02-09 14:49n", "2009-03-11 02:38_", "2009-04-09 14:56_", "2009-05-09 04:01_", "2009-06-07 18:12_", "2009-07-07 09:21n", "2009-08-06 00:55n", "2009-09-04 16:03_", "2009-10-04 06:10_", "2009-11-02 19:14_", "2009-12-02 07:30_", "2009-12-31 19:13p", "2010-01-30 06:18_", "2010-02-28 16:38_", "2010-03-30 02:25_", "2010-04-28 12:18_", "2010-05-27 23:07_", "2010-06-26 11:30p", "2010-07-26 01:37_", "2010-08-24 17:05_", "2010-09-23 09:17_", "2010-10-23 01:36_", "2010-11-21 17:27_", "2010-12-21 08:13t", "2011-01-19 21:21_", "2011-02-18 08:36_", "2011-03-19 18:10_", "2011-04-18 02:44_", "2011-05-17 11:09_", "2011-06-15 20:13t", "2011-07-15 06:40_", "2011-08-13 18:58_", "2011-09-12 09:27_", "2011-10-12 02:06_", "2011-11-10 20:16_", "2011-12-10 14:36t", "2012-01-09 07:30_", "2012-02-07 21:54_", "2012-03-08 09:40_", "2012-04-06 19:19_", "2012-05-06 03:35_", "2012-06-04 11:12p", "2012-07-03 18:52_", "2012-08-02 03:27_", "2012-08-31 13:58_", "2012-09-30 03:19_", "2012-10-29 19:50_", "2012-11-28 14:46n", "2012-12-28 10:21_", "2013-01-27 04:38_", "2013-02-25 20:26_", "2013-03-27 09:27_", "2013-04-25 19:57p", "2013-05-25 04:25n", "2013-06-23 11:32_", "2013-07-22 18:15_", "2013-08-21 01:45_", "2013-09-19 11:13_", "2013-10-18 23:38n", "2013-11-17 15:16_", "2013-12-17 09:28_", "2014-01-16 04:52_", "2014-02-14 23:53_", "2014-03-16 17:09_", "2014-04-15 07:42t", "2014-05-14 19:16_", "2014-06-13 04:11_", "2014-07-12 11:25_", "2014-08-10 18:09_", "2014-09-09 01:38_", "2014-10-08 10:51t", "2014-11-06 22:23_", "2014-12-06 12:27_", "2015-01-05 04:53_", "2015-02-03 23:09_", "2015-03-05 18:06_", "2015-04-04 12:06p", "2015-05-04 03:42_", "2015-06-02 16:19_", "2015-07-02 02:20_", "2015-07-31 10:43_", "2015-08-29 18:35_", "2015-09-28 02:50t", "2015-10-27 12:05_", "2015-11-25 22:44_", "2015-12-25 11:11_", "2016-01-24 01:46_", "2016-02-22 18:20_", "2016-03-23 12:01n", "2016-04-22 05:24_", "2016-05-21 21:15_", "2016-06-20 11:02_", "2016-07-19 22:57_", "2016-08-18 09:27_", "2016-09-16 19:05n", "2016-10-16 04:23_", "2016-11-14 13:52_", "2016-12-14 00:06_", "2017-01-12 11:34_", "2017-02-11 00:33n", "2017-03-12 14:54_", "2017-04-11 06:08_", "2017-05-10 21:43_", "2017-06-09 13:10_", "2017-07-09 04:07_", "2017-08-07 18:11p", "2017-09-06 07:03_", "2017-10-05 18:40_", "2017-11-04 05:23_", "2017-12-03 15:47_", "2018-01-02 02:24_", "2018-01-31 13:27t", "2018-03-02 00:51_", "2018-03-31 12:37_", "2018-04-30 00:58_", "2018-05-29 14:20_", "2018-06-28 04:53_", "2018-07-27 20:20t", "2018-08-26 11:56_", "2018-09-25 02:53_", "2018-10-24 16:45_", "2018-11-23 05:39_", "2018-12-22 17:49_")
@@ -516,7 +516,7 @@ class DataModel():
self.next_new_moon_date = the_date + next_new_moon_sec - self.correct_for_tz_and_dst(the_date + next_new_moon_sec)
self.days_until_full_moon = next_full_moon_sec / SECONDS_PER_DAY
self.next_full_moon_date = the_date + next_full_moon_sec - self.correct_for_tz_and_dst(the_date + next_full_moon_sec)
-
+
# Eclipse information
self.next_lunar_eclipse_sec = self.next_lunar_eclipse_sec_at_time(the_date)
self.next_solar_eclipse_sec = self.next_solar_eclipse_sec_at_time(the_date)
@@ -546,7 +546,7 @@ class DataModel():
self.rise_or_set = _("Sunset")
else:
self.rise_or_set = _("Sunrise")
-
+
def correct_for_tz_and_dst(self, date_sec_of_event):
"""Time-zone and/or daylight-saving correction (internal data is UTC).
"""
@@ -691,4 +691,4 @@ class DataModel():
next = time.mktime(time.strptime(date_string[:-1], self.date_format))
if next >= now:
return next - now
- return -1
+ return -1 \ No newline at end of file