cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #02988
[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/58962
Redoing some markup that changed in Bash.org, and Qdb.us
--
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote/+merge/58962
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/BashParser.py'
--- Quote/BashParser.py 2010-11-23 21:01:19 +0000
+++ Quote/BashParser.py 2011-04-25 15:02:36 +0000
@@ -12,6 +12,7 @@
self.url = "http://bash.org/?random"
self.quote = []
self.inside_p_element = False # indica se o parser esta dentro de <p></p> tag
+ self.inside_nickname = False # <p>"<nickname>phrase"</p>
self.current_quote = ""
def start_p(self, attrs):
@@ -20,15 +21,23 @@
self.inside_p_element = True
def end_p(self):
- self.inside_p_element = False
- self.quote.append(self.current_quote) # adiciona o conteudo completo da tag
- self.current_quote = "" # reinicia o armazenador do conteudo
+ if self.inside_p_element:
+ self.quote.append(self.current_quote) # adiciona o conteudo completo da tag
+ self.current_quote = "" # reinicia o armazenador do conteudo
+ self.inside_p_element = False
def handle_data(self, text):
if self.inside_p_element: # estamos dentro de <p>...</p>
- text = text.replace('<', '[') # se a string contem '<nome>', gera o erro na hora do ShowDialog
- text = text.replace('>', ']') # pango_layout_set_markup_with_accel: Unknown tag 'nome'
- self.current_quote += text # concatena tudo que tiver dentro da tag
+ if not self.inside_nickname: # <nickname> quote
+ if text == '<': # entered the "nickname area"
+ self.inside_nickname = True
+ self.current_quote += '\n<' # linebreak
+ else:
+ self.current_quote += text # concatena tudo que tiver dentro da tag
+ else:
+ self.current_quote += text # concatenate all the nickname
+ if text == '>': # nickname is over
+ self.inside_nickname = False # set it
def parse(self, page):
self.feed(page) # feed the parser with the page's html
=== modified file 'Quote/QdbParser.py'
--- Quote/QdbParser.py 2010-11-23 21:01:19 +0000
+++ Quote/QdbParser.py 2011-04-25 15:02:36 +0000
@@ -12,6 +12,7 @@
self.url = "http://www.qdb.us/random"
self.quote = []
self.inside_span_element = False # indica se o parser esta dentro de <span></span> tag
+ self.inside_nickname = False # <p>"<nickname>phrase"</p>
self.current_quote = ""
def start_span(self, attrs):
@@ -26,9 +27,16 @@
def handle_data(self, text):
if self.inside_span_element: # estamos dentro de <span>...</span>
- text = text.replace('<', '[') # se a string contem '<nome>', gera o erro na hora do ShowDialog
- text = text.replace('>', ']') # pango_layout_set_markup_with_accel: Unknown tag 'nome'
- self.current_quote += text # concatena tudo que tiver dentro da tag
+ if not self.inside_nickname: # <nickname> quote
+ if text == '<': # entered the "nickname area"
+ self.inside_nickname = True
+ self.current_quote += '\n<' # linebreak
+ else:
+ self.current_quote += text # concatena tudo que tiver dentro da tag
+ else:
+ self.current_quote += text # concatenate all the nickname
+ if text == '>': # nickname is over
+ self.inside_nickname = False # set it
def parse(self, page):
self.feed(page) # feed the parser with the page's html
Follow ups