cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #04243
[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/106534
Quote: Added Chucknorrisfacts.fr
--
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote/+merge/106534
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'
--- Quote/ChangeLog 2012-05-14 20:09:51 +0000
+++ Quote/ChangeLog 2012-05-20 16:00:25 +0000
@@ -1,3 +1,4 @@
+0.1.4:(May/20/2012): Added Chucknorrisfacts.fr.
0.1.3:(May/13/2012): Added Fmylife.com, Vitadimerda.it, and 100blagues.com.
0.1:(May/13/2012): Added Viedemerde.fr, and more documentation on the code
0.0.9:(March/28/2012): Removed Grouphug.us because it is not offering the random quote anymore. Fixing the return from Bash and Qdb.
=== added file 'Quote/ChucknorrisfactsfrParser.py'
--- Quote/ChucknorrisfactsfrParser.py 1970-01-01 00:00:00 +0000
+++ Quote/ChucknorrisfactsfrParser.py 2012-05-20 16:00:25 +0000
@@ -0,0 +1,33 @@
+# 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 ChucknorrisfactsfrParser(SGMLParser):
+
+ def reset(self):
+ SGMLParser.reset(self)
+ self.url = "http://www.chucknorrisfacts.fr/index.php?p=parcourir&tri=aleatoire"
+ self.quote = [] # list of quotes to be filled
+ self.inside_div_element = False # indicates if the parser is inside the <div></div> tag
+ self.current_quote = ""
+
+ def start_div(self, attrs):
+ for name, value in attrs:
+ if name == "class" and value == "fact": # <div class="fact">...</div>
+ self.inside_div_element = True
+
+ def end_div(self):
+ self.quote.append(self.current_quote)
+ self.current_quote = ""
+ self.inside_div_element = False
+
+ def handle_data(self, text):
+ if self.inside_div_element: # Concatenate all the content inside <div>...</div>
+ self.current_quote += text
+
+ def parse(self, page):
+ self.feed(page) # feed the parser with the page's html
+ self.close()
=== modified file 'Quote/Quote'
--- Quote/Quote 2012-05-14 20:09:51 +0000
+++ Quote/Quote 2012-05-20 16:00:25 +0000
@@ -19,7 +19,7 @@
# such as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.fr,
# Jokes2go.com, and Vidademerda.com.br
-import gobject, gtk, urllib, itertools
+import gtk, urllib, itertools
from sgmllib import SGMLParser
from urllib import FancyURLopener
from util import log
@@ -31,7 +31,7 @@
# 1.1 - For specific parts on the creation of the parser, refer to BashParser, some documentation is there
# 2 - Import it "from MyWebSiteParser (module name) import MyWebSiteParser (class name)"
# 3 - Add one identificator for the parser, for example, "quotationspage" = 1. Look that we already have
-# seven parsers = range(8). For each new one you add, you have increment the parameter on the range method
+# many parsers. For each new one you add, you have increment the parameter on the range method
# 4 - On the fetch method, add a new block
# elif (self.source == mywebsite):
# parser = MyNewWebSiteParser
@@ -49,9 +49,10 @@
from FmylifeParser import FmylifeParser # Fmylife.com
from VitadimerdaParser import VitadimerdaParser # VitadimerdaParser.it
from HundredblaguesParser import HundredblaguesParser # HundredblaguesParser.com
+from ChucknorrisfactsfrParser import ChucknorrisfactsfrParser # Chucknorrisfacts.fr
-# quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5, vidademerda = 6, viedemerde = 7, fmylife = 8, vitadimerda = 9, hundredblagues = 10
-quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo, vidademerda, viedemerde, fmylife, vitadimerda, hundredblagues = range(11)
+# quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5, vidademerda = 6, viedemerde = 7, fmylife = 8, vitadimerda = 9, hundredblagues = 10, chucknorrisfactsfr = 11
+quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo, vidademerda, viedemerde, fmylife, vitadimerda, hundredblagues, chucknorrisfactsfr = range(12)
class AgentOpener(FancyURLopener):
"""Masked user-agent otherwise the access would be forbidden"""
@@ -76,17 +77,19 @@
elif self.source == danstonchat:
parser = DanstonchatParser() # DanstonchatParser.py
elif self.source == jokestogo:
- parser = JokestogoParser()
- elif self.source == vidademerda: # VidademerdaParser.py
- parser = VidademerdaParser()
+ parser = JokestogoParser() # JokestogoParser.py
+ elif self.source == vidademerda:
+ parser = VidademerdaParser() # VidademerdaParser.py
elif self.source == viedemerde:
parser = ViedemerdeParser() # ViedemerdeParser.py
elif self.source == fmylife:
parser = FmylifeParser() # FmylifeParser.py
elif self.source == vitadimerda:
parser = VitadimerdaParser() # VitadimerdaParser.py
- else:
- parser = HundredblaguesParser()
+ elif self.source == hundredblagues:
+ parser = HundredblaguesParser() # HundredblaguesParser.py
+ else:
+ parser = ChucknorrisfactsfrParser()
opener = AgentOpener() # opens the web connection with masked user-agent
@@ -101,10 +104,10 @@
# Handle different kind of returns from the parser. It is necessary because some sources return quotes with extra
# characters that we need to filter here. Some come with extra '', others come with linebreaks, etc.
- if (self.source == quotationspage):
+ if self.source == quotationspage:
self.quote = parser.quote
self.author = parser.author
- elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues]:
+ elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues, chucknorrisfactsfr]:
self.quote = filter(None, parser.quote) # remove the '' from the array
elif self.source == jokestogo: # jokestogo
self.quote = filter(self.linebreak, parser.quote) # remove linebreak from the array
@@ -127,7 +130,7 @@
self.go_next_quote_key = 1
self.source = quotationspage
self.names = ["Quotationspage.com","Bash.org","Xkcdb.com","Qdb.us","Danstonchat.com","Jokes2go.com",
- "Vidademerda.com.br","Viedemerde.fr","Fmylife.com", "Vitadimerda.it", "100blagues.com"]
+ "Vidademerda.com.br","Viedemerde.fr","Fmylife.com", "Vitadimerda.it", "100blagues.com", "Chucknorrisfacts.fr"]
CDApplet.__init__(self) # call high-level init
@@ -152,7 +155,7 @@
def show_quote(self):
if (self.source == quotationspage):
self.quotation = "\"%s\" ~ %s" % (self.quotes.next(), self.authors.next()) # quote[x] ~ author[x]
- elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues]:
+ elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues, chucknorrisfactsfr]:
try: # check if it is possible to show the already stored quotes
current = self.quotes.next()
except StopIteration: # all were already shown
=== modified file 'Quote/Quote.conf'
--- Quote/Quote.conf 2012-05-14 20:09:51 +0000
+++ Quote/Quote.conf 2012-05-20 16:00:25 +0000
@@ -1,4 +1,4 @@
-#0.1.3
+#0.1.4
#[gtk-about]
[Icon]
@@ -102,5 +102,5 @@
#[gtk-preferences]
[Configuration]
-#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com;Vidademerda.com.br;Viedemerde.fr;Fmylife.com;Vitadimerda.it;100blagues.com] Quote source:
+#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com;Vidademerda.com.br;Viedemerde.fr;Fmylife.com;Vitadimerda.it;100blagues.com;Chucknorrisfacts.fr] Quote source:
source = 1
=== modified file 'Quote/auto-load.conf'
--- Quote/auto-load.conf 2012-05-14 20:09:51 +0000
+++ Quote/auto-load.conf 2012-05-20 16:00:25 +0000
@@ -4,13 +4,13 @@
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 such as:\n Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, Jokes2go.com, Vidademerda.com.br, Viedemerde.fr, Fmylife.com, Vitadimerda.it, and 100blagues.com.
+description = This applet provides a "Quote of the day" feature from some internet sources such as:\n Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, Jokes2go.com, Vidademerda.com.br, Viedemerde.fr, Fmylife.com, Vitadimerda.it, 100blagues.com, and Chucknorrisfacts.fr.
# 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.1.3
+version = 0.1.4
# Whether the applet can be instanciated several times or not.
multi-instance = true
Follow ups