cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #02780
[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote into lp:cairo-dock-plug-ins-extras
Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote into lp:cairo-dock-plug-ins-extras.
Requested reviews:
Cairo-Dock Team (cairo-dock-team)
For more details, see:
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote/+merge/47691
Fixing the message when there were no translation for only one word. Adding Vidademerda.com.br. Adding next quote button in the PopupDialog.
--
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote/+merge/47691
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote into lp:cairo-dock-plug-ins-extras.
=== modified file 'Quote/ChangeLog' (properties changed: -x to +x)
--- Quote/ChangeLog 2010-12-22 14:19:10 +0000
+++ Quote/ChangeLog 2011-01-27 16:54:12 +0000
@@ -1,3 +1,4 @@
+0.0.7:(January/27/2010): Fixing the message when there were no translation for only one word. Adding Vidademerda.com.br. Adding next quote button in the PopupDialog.
0.0.6:(December/22/2010): Automatic fetch more quotes when all of them were already showed to the user, except for Quotationspage.com.
0.0.5:(December/2/2010): Added Jokes2go.com.
0.0.4:(November/23/2010): Added Danstonchat.com. Changed the icon, now the lamp was turned on :¬) Huge code modularization.
=== modified file 'Quote/Quote'
--- Quote/Quote 2010-12-22 14:19:10 +0000
+++ Quote/Quote 2011-01-27 16:54:12 +0000
@@ -16,8 +16,8 @@
# GNU General Public License for more details.
# This applet provides a "Quote of the day" feature from some internet sources
-# such as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.fr, and
-# Jokes2go.com
+# such as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.fr,
+# Jokes2go.com, and Vidademerda.com.br
import gobject, dbus, os, urllib, gtk, ConfigParser, itertools
from dbus.mainloop.glib import DBusGMainLoop
@@ -32,10 +32,11 @@
from QuotationspageParser import QuotationspageParser # Quotationspage.com
from DanstonchatParser import DanstonchatParser # Danstonchat.fr
from JokestogoParser import JokestogoParser # Jokes2go.com
+from VidademerdaParser import VidademerdaParser # Vidademerda.com.br
DBusGMainLoop(set_as_default=True)
-quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo = range(6) # quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5
+quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo, vidademerda = range(7) # quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5, vidademerda = 6
class AgentOpener(FancyURLopener):
"""Masked user-agent otherwise the access would be forbidden"""
@@ -59,8 +60,10 @@
parser = QdbParser() # QdbParser.py
elif (self.source == danstonchat):
parser = DanstonchatParser() # DanstonchatParser.py
- else:
+ elif (self.source == jokestogo):
parser = JokestogoParser()
+ else:
+ parser = VidademerdaParser()
opener = AgentOpener() # opens the web connection with masked user-agent
@@ -76,8 +79,11 @@
self.author = parser.author
elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat):
self.quote = filter(None, parser.quote) # retira os '' do array
- else: # jokestogo
+ elif self.source == jokestogo: # jokestogo
self.quote = filter(self.breakline, parser.quote)
+ else: # vidademerda
+ self.quote = [''.join(parser.quote)]
+ self.author = parser.author
return self.quote, self.author
def breakline(self, item):
@@ -110,6 +116,7 @@
self.quotation = ""
self.dialog_active_time = 30 # time in seconds that the dialog window will be active
self.copy_current_quote_key = 0
+ self.go_next_quote_key = 1
self.source = quotationspage
def start(self):
@@ -139,6 +146,8 @@
def action_on_answer_dialog(self, key, content):
if (key == self.copy_current_quote_key): # cancel button = 1, and copy_current_quote_key = 0
self.set_to_clipboard(self.quotation) # copia para a area de transferencia a quotation atual
+ elif (key == self.go_next_quote_key):
+ self.show_quote()
def set_to_clipboard(self, sentence):
clipboard = gtk.clipboard_get() # get the clipboard
@@ -166,13 +175,15 @@
self.get_quotes_from_web() # buscar mais
current = self.quotes.next() # posicionar na primeira para mostra-la
self.quotation = "%s" % current
- else: # jokestogo provides only one quote per request ...
+ elif (self.source == jokestogo): # jokestogo provides only one quote per request ...
self.quotation = "%s" % self.quotes.next().rstrip()
- self.get_quotes_from_web() # ... so it is necessary to request it again
+ self.get_quotes_from_web() # ... so it is necessary to request it again
+ else:
+ self.quotation = "%s ~ %s" % (self.quotes.next(), self.authors.next()) # vidademerda provides only one quote per request ...
+ self.get_quotes_from_web() # ... so it is necessary to request it again
try:
- self.icon.PopupDialog({'message':self.quotation, "buttons":"stock_copy;cancel"}, {})
- except Exception:
- log("Error caused PopupDialog not be shown, ShowDialog was used instead") # back-compatibility with CD < 2.2.0
+ self.icon.PopupDialog({'message':self.quotation, "buttons":"stock_copy;go-next;cancel"}, {})
+ except Exception: # back-compatibility with CD < 2.2.0
self.icon.ShowDialog(self.quotation, self.dialog_active_time)
def inform_start_of_waiting_process(self):
=== modified file 'Quote/Quote.conf'
--- Quote/Quote.conf 2010-12-22 14:19:10 +0000
+++ Quote/Quote.conf 2011-01-27 16:54:12 +0000
@@ -1,4 +1,4 @@
-#!en;0.0.6
+#!en;0.0.7
#[gtk-about]
[Icon]
@@ -89,5 +89,5 @@
#[gtk-preferences]
[Configuration]
-#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com] Quote source:
+#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com;Vidademerda.com.br] Quote source:
source = 0
=== added file 'Quote/VidademerdaParser.py'
--- Quote/VidademerdaParser.py 1970-01-01 00:00:00 +0000
+++ Quote/VidademerdaParser.py 2011-01-27 16:54:12 +0000
@@ -0,0 +1,50 @@
+# This is a part of the external Quote applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+
+from sgmllib import SGMLParser
+
+class VidademerdaParser(SGMLParser):
+
+ def reset(self):
+ SGMLParser.reset(self)
+ self.url = "http://vidademerda.com.br/aleatorias"
+ self.quote = []
+ self.author = []
+ self.inside_div_element = False # indica se o parser esta dentro de <div></div> tag
+ self.inside_div_p_element = False
+ self.inside_b_element = False
+
+ def start_div(self, attrs):
+ for name, value in attrs:
+ if name == "class" and value == "vdmContent": # <dt class="vdmContent">...</dt>
+ self.inside_div_element = True
+
+ def end_div(self):
+ self.inside_div_element = False
+
+ def start_p(self, attrs):
+ if self.inside_div_element:
+ self.inside_div_p_element = True
+
+ def end_p(self):
+ self.inside_div_p_element = False
+
+ def start_b(self, attrs):
+ for name, value in attrs:
+ if name == "class" and value == "ajustM6": # <dt class="ajustM6">...</dt>
+ self.inside_b_element = True
+
+ def end_b(self):
+ self.inside_b_element = False
+
+ def handle_data(self, text):
+ if self.inside_div_p_element: # estamos dentro de <div><p>...</p></div>
+ self.quote.append(text)
+ if self.inside_b_element:
+ self.author.append(text)
+
+ def parse(self, page):
+ self.feed(page) # feed the parser with the page's html
+ self.close()
=== modified file 'Quote/auto-load.conf' (properties changed: -x to +x)
--- Quote/auto-load.conf 2010-12-22 14:19:10 +0000
+++ Quote/auto-load.conf 2011-01-27 16:54:12 +0000
@@ -4,10 +4,10 @@
author = Eduardo Mucelli Rezende Oliveira
# A short description of the applet and how to use it.
-description = This applet provides a "Quote of the day" feature from some internet sources \nsuch as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, and Jokes2go.com
+description = This applet provides a "Quote of the day" feature from some internet sources \nsuch as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, Jokes2go.com, and Vidademerda.com.br
# Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
category = 7
# 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.
-version = 0.0.6
+version = 0.0.7
Follow ups