From 18df6e7fa892cf85dda074a7044ce586ecf17c77 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Sun, 20 Jul 2014 10:56:50 +0900 Subject: [PATCH] suggest fix for #20 --- rainbowstream/draw.py | 10 +++------- rainbowstream/py3patch.py | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index f23e4ca..4360d46 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -20,11 +20,6 @@ db = RainbowDB() g = {} -def unescape(s): - p = HTMLParser() - return p.unescape(s) - - def init_cycle(): """ Init the cycle @@ -163,11 +158,12 @@ def draw(t, iot=False, keyword=None, check_semaphore=False, fil=[], ig=[]): # Pull extended retweet text try: - text = 'RT @{0}: {1}'.format(t['retweeted_status']['user']['screen_name'], - t['retweeted_status']['text']) + text = 'RT @' + t['retweeted_status']['user']['screen_name'] + ': ' +\ + t['retweeted_status']['text'] except: pass + # Unescape HTML character text = unescape(text) # Get expanded url diff --git a/rainbowstream/py3patch.py b/rainbowstream/py3patch.py index 6042984..83e5f0a 100644 --- a/rainbowstream/py3patch.py +++ b/rainbowstream/py3patch.py @@ -13,8 +13,11 @@ except: try: from HTMLParser import HTMLParser + def unescape(s): + p = HTMLParser() + return p.unescape(s) except: - from html.parser import HTMLParser + from html import unescape # raw_input and map functiion behaviour if sys.version[0] == "3": -- 2.25.1