← Back to team overview

cairo-dock-team team mailing list archive

[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/105717

Quote: Added Fmylife.com, Vitadimerda.it, and 100blagues.com.
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote/+merge/105717
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-13 12:19:19 +0000
+++ Quote/ChangeLog	2012-05-14 20:28:17 +0000
@@ -1,3 +1,4 @@
+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.
 0.0.8:(March/17/2010): Added Grouphug.us.

=== modified file 'Quote/DanstonchatParser.py'
--- Quote/DanstonchatParser.py	2011-02-22 02:08:47 +0000
+++ Quote/DanstonchatParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
 	def reset(self):                              
 		SGMLParser.reset(self)
+		self.name = "Danstonchat.com"
 		self.url = "http://danstonchat.com/random.html";
 		self.quote = []
 		self.inside_div_element = False                                             # indica se o parser esta dentro de <span></span> tag

=== added file 'Quote/FmylifeParser.py'
--- Quote/FmylifeParser.py	1970-01-01 00:00:00 +0000
+++ Quote/FmylifeParser.py	2012-05-14 20:28:17 +0000
@@ -0,0 +1,42 @@
+# 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 FmylifeParser(SGMLParser):
+
+  def reset(self):
+    SGMLParser.reset(self)
+    self.url = "http://www.fmylife.com/random";
+    self.quote = []                                         # list of quotes to be filled
+    self.inside_div_element = False                         # indicates if the parser is inside the <div></div> tag
+    self.inside_div_p_element = False
+    self.current_quote = ""
+
+  def start_div(self, attrs):
+    for name, value in attrs:
+      if name == "class" and value == "post article":       # <div class="post article">...</div>
+        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                      # Parser is inside <div><p>...</p></div>
+
+  def end_p(self):
+    if self.inside_div_p_element:                           # if this is the end of our specific <div><p> tag,
+      self.quote.append(self.current_quote)                 # append the whole content found inside <div><p>...</p></div>,
+      self.current_quote = ""                               # clear it for the next quote,
+      self.inside_div_p_element = False                     # and mark as finished tag
+
+  def handle_data(self, text):
+    if self.inside_div_p_element:                           # Concatenate all the content inside <div><p>...</p></div>
+      self.current_quote += text
+
+  def parse(self, page):
+    self.feed(page)                                         # feed the parser with the page's html
+    self.close() 

=== added file 'Quote/HundredblaguesParser.py'
--- Quote/HundredblaguesParser.py	1970-01-01 00:00:00 +0000
+++ Quote/HundredblaguesParser.py	2012-05-14 20:28:17 +0000
@@ -0,0 +1,51 @@
+# 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 HundredblaguesParser(SGMLParser):
+
+  def reset(self):
+    SGMLParser.reset(self)
+    self.url = "http://www.100blagues.com/random";
+    self.quote = []                                         # list of quotes to be filled
+    self.inside_div_element = False                         # indicates if the parser is inside the <div></div> tag
+    self.inside_div_p_element = False
+    self.inside_div_p_a_element = False
+    self.current_quote = ""
+
+  def start_div(self, attrs):
+    for name, value in attrs:
+      if name == "class" and value == "post":               # <div class="post">...</div>
+        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                      # Parser is inside <div><p>...</p></div>
+
+  def end_p(self):
+    if self.inside_div_p_element:                           # if this is the end of our specific <div><p> tag,
+      self.inside_div_p_element = False
+  
+  def start_a(self, attrs):
+    if self.inside_div_p_element:
+      self.inside_div_p_a_element = True
+  
+  def end_a(self):
+    if self.inside_div_p_a_element:
+      self.quote.append(self.current_quote)                 # append the whole content found inside <div><p><a>...</a></p></div>,
+      self.current_quote = ""                               # clear it for the next quote,
+      self.inside_div_p_a_element = False                   # and mark as finished tag    
+
+  def handle_data(self, text):
+    if self.inside_div_p_a_element:                         # Concatenate all the content inside <div><p><a>...</a></p></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/JokestogoParser.py'
--- Quote/JokestogoParser.py	2010-12-02 10:17:59 +0000
+++ Quote/JokestogoParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
     def reset(self):                              
         SGMLParser.reset(self)
+        self.name = "Jokes2go.com"
         self.url = "http://www.jokes2go.com/cgi-perl/randjoke.cgi?type=j";
         self.quote = []
         self.inside_pre_element = False                                             # indica se o parser esta dentro de <pre></pre> tag

=== modified file 'Quote/QdbParser.py'
--- Quote/QdbParser.py	2012-03-28 20:50:03 +0000
+++ Quote/QdbParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
     def reset(self):                              
         SGMLParser.reset(self)
+        self.name = "Qdb.us"
         self.url = "http://www.qdb.us/random";
         self.quote = []
         self.inside_span_element = False                                            # indica se o parser esta dentro de <span></span> tag

=== modified file 'Quote/QuotationspageParser.py'
--- Quote/QuotationspageParser.py	2010-11-23 21:01:19 +0000
+++ Quote/QuotationspageParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
     def reset(self):
         SGMLParser.reset(self)
+        self.name = "Quotationspage.com"
         self.url = "http://www.quotationspage.com/qotd.html";
         self.quote = []
         self.author = []

=== modified file 'Quote/Quote'
--- Quote/Quote	2012-05-13 12:19:19 +0000
+++ Quote/Quote	2012-05-14 20:28:17 +0000
@@ -46,9 +46,12 @@
 from JokestogoParser import JokestogoParser                             # Jokes2go.com
 from VidademerdaParser import VidademerdaParser                         # Vidademerda.com.br
 from ViedemerdeParser import ViedemerdeParser                           # Viedemerde.fr
+from FmylifeParser import FmylifeParser                                 # Fmylife.com
+from VitadimerdaParser import VitadimerdaParser                         # VitadimerdaParser.it
+from HundredblaguesParser import HundredblaguesParser                   # HundredblaguesParser.com
 
-# quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5, vidademerda = 6, viedemerde = 7
-quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo, vidademerda, viedemerde = range(8)  
+# 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)  
 
 class AgentOpener(FancyURLopener):
   """Masked user-agent otherwise the access would be forbidden"""
@@ -62,22 +65,28 @@
     self.quote = []                                                     # List of quotes of the current source
 
   def fetch(self):
-    if (self.source == quotationspage):
+    if self.source == quotationspage:
       parser = QuotationspageParser()                                   # QuotationspageParser.py
-    elif (self.source == bash):
+    elif self.source == bash:
       parser = BashParser()                                             # BashParser.py
-    elif (self.source == xkcdb):
+    elif self.source == xkcdb:
       parser = XkcdbParser()                                            # XkcdbParser.py
-    elif (self.source == qdb):
+    elif self.source == qdb:
       parser = QdbParser()                                              # QdbParser.py
-    elif (self.source == danstonchat):
+    elif self.source == danstonchat:
       parser = DanstonchatParser()                                      # DanstonchatParser.py
-    elif (self.source == jokestogo):
+    elif self.source == jokestogo:
       parser = JokestogoParser()
-    elif (self.source == vidademerda):                                  # VidademerdaParser.py
+    elif self.source == vidademerda:                                    # VidademerdaParser.py
       parser = VidademerdaParser()
-    else:                                                               # ViedemerdeParser.py
-      parser = ViedemerdeParser()
+    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()
 
     opener = AgentOpener()                                              # opens the web connection with masked user-agent
 
@@ -88,13 +97,14 @@
     else:
       parser.parse(page.read())                                         # feed the parser with the page's content
       page.close()                                                      # close the page connection
-      
+            
       # 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):  
         self.quote = parser.quote
         self.author = parser.author
-      elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat or self.source == viedemerde):
+      elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues]:
         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
@@ -116,7 +126,8 @@
     self.copy_current_quote_key = 0
     self.go_next_quote_key = 1
     self.source = quotationspage
-    self.cSiteNames = ['Quotationspage.com','Bash.org','Xkcdb.com','Qdb.us','Danstonchat.com','Jokes2go.com','Vidademerda.com.br', 'Viedemerde.fr']
+    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"]
     
     CDApplet.__init__(self)                                             # call high-level init
   
@@ -141,7 +152,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 == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat or self.source == viedemerde):
+    elif self.source in [bash, xkcdb, qdb, danstonchat, viedemerde, fmylife, vitadimerda, hundredblagues]:
       try:                                                              # check if it is possible to show the already stored quotes
         current = self.quotes.next()
       except StopIteration:                                             # all were already shown
@@ -162,14 +173,14 @@
   def inform_end_of_waiting_process(self):
     self.icon.SetQuickInfo("")
   
-  def _display_site_name(self):
+  def display_source_name(self):
     if self.config['default title'] == "":
-      self.icon.SetLabel(self.cSiteNames[self.source])
+      self.icon.SetLabel(self.names[self.source])
   
   # Inherited methods from CDApplet
   def begin(self):
     self.get_quotes_from_web()
-    self._display_site_name()
+    self.display_source_name()
 
   def get_config(self, keyfile):
     self.source = keyfile.getint('Configuration', 'source')             # get the source of quotations
@@ -177,7 +188,7 @@
 
   def reload(self):
     self.get_quotes_from_web()                                          # refresh the quotations
-    self._display_site_name()
+    self.display_source_name()
 
   # Callbacks
   def on_click(self, key):

=== modified file 'Quote/Quote.conf'
--- Quote/Quote.conf	2012-05-13 12:19:19 +0000
+++ Quote/Quote.conf	2012-05-14 20:28:17 +0000
@@ -1,4 +1,4 @@
-#0.1
+#0.1.3
 
 #[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] 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] Quote source:
 source = 1

=== modified file 'Quote/VidademerdaParser.py'
--- Quote/VidademerdaParser.py	2011-01-27 16:46:43 +0000
+++ Quote/VidademerdaParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
     def reset(self):
         SGMLParser.reset(self)
+        self.name = "Vidademerda.com.br"
         self.url = "http://vidademerda.com.br/aleatorias";
         self.quote = []
         self.author = []

=== modified file 'Quote/ViedemerdeParser.py'
--- Quote/ViedemerdeParser.py	2012-05-14 16:32:42 +0000
+++ Quote/ViedemerdeParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
   def reset(self):
     SGMLParser.reset(self)
+    self.name = "Viedemerde.fr"
     self.url = "http://www.viedemerde.fr/aleatoire";
     self.quote = []                                         # list of quotes to be filled
     self.inside_div_element = False                         # indicates if the parser is inside the <div></div> tag

=== added file 'Quote/VitadimerdaParser.py'
--- Quote/VitadimerdaParser.py	1970-01-01 00:00:00 +0000
+++ Quote/VitadimerdaParser.py	2012-05-14 20:28:17 +0000
@@ -0,0 +1,42 @@
+# 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 VitadimerdaParser(SGMLParser):
+
+  def reset(self):
+    SGMLParser.reset(self)
+    self.url = "http://www.vitadimerda.it/aleatorie";
+    self.quote = []                                         # list of quotes to be filled
+    self.inside_div_element = False                         # indicates if the parser is inside the <div></div> tag
+    self.inside_div_p_element = False
+    self.current_quote = ""
+
+  def start_div(self, attrs):
+    for name, value in attrs:
+      if name == "class" and value == "post article":       # <div class="post article">...</div>
+        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                      # Parser is inside <div><p>...</p></div>
+
+  def end_p(self):
+    if self.inside_div_p_element:                           # if this is the end of our specific <div><p> tag,
+      self.quote.append(self.current_quote)                 # append the whole content found inside <div><p>...</p></div>,
+      self.current_quote = ""                               # clear it for the next quote,
+      self.inside_div_p_element = False                     # and mark as finished tag
+
+  def handle_data(self, text):
+    if self.inside_div_p_element:                           # Concatenate all the content inside <div><p>...</p></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/XkcdbParser.py'
--- Quote/XkcdbParser.py	2010-11-23 21:01:19 +0000
+++ Quote/XkcdbParser.py	2012-05-14 20:28:17 +0000
@@ -9,6 +9,7 @@
 
     def reset(self):                              
         SGMLParser.reset(self)
+        self.name = "Xkcdb.com"
         self.url = "http://www.xkcdb.com/?random";
         self.quote = []
         self.inside_span_element = False                                               # indica se o parser esta dentro de <p></p> tag

=== modified file 'Quote/auto-load.conf'
--- Quote/auto-load.conf	2012-05-13 12:19:19 +0000
+++ Quote/auto-load.conf	2012-05-14 20:28:17 +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, and Viedemerde.fr
+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.
 
 # 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
+version = 0.1.3
 
 # Whether the applet can be instanciated several times or not.
 multi-instance = true


Follow ups