Merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by Eduardo Mucelli Rezende Oliveira
Status: Merged
Merged at revision: 186
Proposed branch: lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 182 lines (+42/-23)
4 files modified
Moon/ChangeLog (+1/-0)
Moon/Moon (+35/-20)
Moon/Moon.conf (+4/-1)
Moon/auto-load.conf (+2/-2)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon
Reviewer Review Type Date Requested Status
Cairo-Dock Devs Pending
Review via email: mp+67097@code.launchpad.net

Description of the change

Adding support the perspective of the Southern Hemisphere.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Moon/ChangeLog'
2--- Moon/ChangeLog 2011-05-24 14:44:30 +0000
3+++ Moon/ChangeLog 2011-07-06 22:06:00 +0000
4@@ -1,3 +1,4 @@
5+0.0.4: (July/6/2011): Adding support the perspective of the Southern Hemisphere.
6 0.0.3: (May/24/2011): Fixing a non sub-icons cleaning problem. Adding moon00b.gif that I forgot. Changing the whole icon set, using the icons created by Presto-X -- http://presto-x.deviantart.com/art/Presto-s-Moon-Phases-53625689
7 0.0.2: (May/22/2011): Able to show the moon informations for all the current week. Using the FancyURLopener opener instead of urllib2, I do not know why I was using urllib2.
8 0.0.1: (May/12/2011): Moon applet was created with the possibility to show the moon phases as its own icon, and to show some informations. The service used in this applet was created by Brian Casey -- http://www.briancasey.org/artifacts/astro/moon.cgi
9
10=== modified file 'Moon/Moon'
11--- Moon/Moon 2011-05-24 14:44:30 +0000
12+++ Moon/Moon 2011-07-06 22:06:00 +0000
13@@ -16,6 +16,7 @@
14 # GNU General Public License for more details.
15
16 # This applet displays the moon phases and its informations for the current day or week
17+# from the Northern or Southern hemisphere
18
19 import urllib, datetime, os, re
20 from sgmllib import SGMLParser
21@@ -39,7 +40,7 @@
22
23 def fetch(self):
24 parser = MoonCalendarParser()
25- opener = AgentOpener() # opens the web connection with masked user-agent
26+ opener = AgentOpener() # opens the web connection with masked user-agent
27 params = urllib.urlencode({'year': self.year, 'month': self.month, 'day': self.day})
28
29 try:
30@@ -47,8 +48,8 @@
31 except IOError:
32 log("Problem to open %s" % (parser.url))
33 else:
34- parser.parse(page.read()) # feed the parser to get the specific content: translated text
35- page.close() # lets close the page connection
36+ parser.parse(page.read()) # feed the parser to get the specific content: translated text
37+ page.close() # lets close the page connection
38 self.information = parser.information
39 self.moon_image = parser.moon_image
40 return self.moon_image, self.information
41@@ -61,73 +62,87 @@
42 def inform_end_of_waiting_process(self):
43 self.icon.SetQuickInfo("")
44
45- def flatten(self, array): # Ruby method :-)
46+ def flatten(self, array): # Ruby method :-)
47 return [item for sublist in array for item in sublist]
48
49 def clean(self, string):
50- return re.sub("\s+\n\s+" , " \n", string) # " ".join(information.split())
51+ return re.sub("\s+\n\s+" , " \n", string) # " ".join(information.split())
52
53 def clean_week_icons(self):
54 self.sub_icons.RemoveSubIcon("any")
55
56+ def name_of_the_day(self, day):
57+ days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
58+ return days[datetime.date.weekday(day)]
59+
60+ def img_local_path(self, image):
61+ return os.path.abspath("./data/%s" % image)
62+
63 def get_moon_from_web(self):
64 self.inform_start_of_waiting_process()
65
66 self.clean_week_icons()
67 # TODO: Remove code duplication
68- if self.show_week_moon: # week information
69+ if self.show_week_moon: # week information
70 today = datetime.date.today()
71 tomorrow = datetime.timedelta(days=1)
72- end_of_the_week = datetime.date.today() + datetime.timedelta(days=6)
73+ last_day = datetime.date.today() + datetime.timedelta(days=6)
74 week = [] # ['namesubicon1','imagesubicon1','idsubicon1', 'namesubicon2' ...]
75 self.week_information = []
76 id = 0
77- while today <= end_of_the_week:
78+ while today <= last_day:
79 ye, mo, da = today.timetuple()[:3]
80 interface = Interface(ye, mo, da)
81 image, information = interface.fetch()
82+ # The website provides images from the Northern perspective, but since
83+ # a) The images differs horizontally by "a", or "b" in its names;
84+ # b) The moon differs horizontally between hemispheres;
85+ # It is just a question of replace "a" (North) by "b" (South)
86+ if self.hemisphere == self.south:
87+ image = image.replace('a','b')
88 self.week_information.append(self.clean(information))
89- day_of_the_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
90- week.append(day_of_the_week[datetime.date.weekday(today)]) # name of the icon is the week day name
91- week.append(os.path.abspath("./data/%s" % image)) # icon image is the moon image
92- week.append(str(id)) # id is a sequential from today (0) until end of the week (6)
93+ week.append(self.name_of_the_day(today))
94+ week.append(self.img_local_path(image))
95+ week.append(str(id)) # id is a sequential from today (0) until end of the week (6)
96 id += 1
97 today += tomorrow
98 # log(week)
99 self.sub_icons.AddSubIcons(week)
100- else: # todays information
101+ else: # todays information
102 ye, mo, da = datetime.date.today().timetuple()[:3]
103 interface = Interface(ye, mo, da)
104 image, information = interface.fetch()
105 self.information = self.clean(information)
106 # os.popen("wget -N -q http://www.briancasey.org/artifacts/astro/image/%s -O %s" % (image, os.path.abspath("./data/%s" % (image))))
107- image = os.path.abspath("./data/%s" % image)
108- self.icon.SetIcon(image)
109+ self.icon.SetIcon(self.img_local_path(image))
110
111 self.inform_end_of_waiting_process()
112
113 def __init__(self):
114
115 self.show_week_moon = False
116+ self.north, self.south = range(2)
117+ self.hemisphere = self.north
118 self.information = ""
119 self.week_information = []
120- self.dialog_active_time = 30 # time in seconds that the dialog window will be active
121+ self.dialog_active_time = 30 # time in seconds that the dialog window will be active
122
123- CDApplet.__init__(self) # call high-level init
124+ CDApplet.__init__(self) # call high-level init
125
126 # Inherited methods from CDApplet
127 def begin(self):
128 self.get_moon_from_web()
129
130 def get_config(self, keyfile):
131- self.show_week_moon = keyfile.getboolean('Configuration', 'week') # get the source of quotations
132+ self.show_week_moon = keyfile.getboolean('Configuration', 'week') # information from the current day or from the whole week
133+ self.hemisphere = keyfile.getboolean('Configuration', 'hemisphere') # view from the north, or south hemisphere
134
135 def reload(self):
136- self.get_moon_from_web() # refresh the moon informations
137+ self.get_moon_from_web() # refresh the moon informations
138
139 # Callbacks
140 def on_click(self, key):
141- if not self.show_week_moon: # avoid useless popup
142+ if not self.show_week_moon: # avoid useless popup
143 self.icon.PopupDialog({'message':self.information, 'time-length':self.dialog_active_time},{})
144
145 def on_click_sub_icon (self, state, sub_icon_id):
146
147=== modified file 'Moon/Moon.conf'
148--- Moon/Moon.conf 2011-05-24 14:44:30 +0000
149+++ Moon/Moon.conf 2011-07-06 22:06:00 +0000
150@@ -1,4 +1,4 @@
151-#!en;0.0.3
152+#!en;0.0.4
153
154 #[gtk-about]
155 [Icon]
156@@ -99,3 +99,6 @@
157 [Configuration]
158 #b Show the moon for all the current week?
159 week = true
160+#l[North;South] Hemisphere:
161+#{You are going to see the moon from the perspective of this hemisphere}
162+hemisphere=0
163
164=== modified file 'Moon/auto-load.conf'
165--- Moon/auto-load.conf 2011-05-24 14:44:30 +0000
166+++ Moon/auto-load.conf 2011-07-06 22:06:00 +0000
167@@ -4,13 +4,13 @@
168 author = Eduardo Mucelli Rezende Oliveira
169
170 # A short description of the applet and how to use it.
171-description = This applet displays the moon phases and its informations for the current day, or week
172+description = This applet displays the moon phases and its informations for the current day, or week from the Northern or Southern hemisphere
173
174 # Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
175 category = 5
176
177 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
178-version = 0.0.3
179+version = 0.0.4
180
181 # Whether the applet can be instanciated several times or not.
182 multi-instance = true

Subscribers

People subscribed via source and target branches