Strings are unicode now.

This commit is contained in:
Bill Dengler 2017-06-17 01:14:09 +00:00
parent 885829a930
commit 1c4db4a10e
4 changed files with 6 additions and 6 deletions

View File

@ -947,8 +947,8 @@ class Controller(object):
x = tweet["coordinates"]["coordinates"][0] x = tweet["coordinates"]["coordinates"][0]
y = tweet["coordinates"]["coordinates"][1] y = tweet["coordinates"]["coordinates"][1]
address = geocoder.reverse_geocode(y, x) address = geocoder.reverse_geocode(y, x)
if event == None: output.speak(address[0].__str__().decode("utf-8")) if event == None: output.speak(address[0].__str__())
else: self.view.show_address(address[0].__str__().decode("utf-8")) else: self.view.show_address(address[0].__str__())
else: else:
output.speak(_(u"There are no coordinates in this tweet")) output.speak(_(u"There are no coordinates in this tweet"))
except GeocoderError: except GeocoderError:

View File

@ -232,7 +232,7 @@ class viewTweet(basicTweet):
rt_count = str(tweet["retweet_count"]) rt_count = str(tweet["retweet_count"])
favs_count = str(tweet["favorite_count"]) favs_count = str(tweet["favorite_count"])
# Gets the client from where this tweet was made. # Gets the client from where this tweet was made.
source = str(re.sub(r"(?s)<.*?>", "", tweet["source"].encode("utf-8"))) source = str(re.sub(r"(?s)<.*?>", "", str(tweet["source"])))
if text == "": if text == "":
if "message" in tweet: if "message" in tweet:
value = "message" value = "message"
@ -254,7 +254,7 @@ class viewTweet(basicTweet):
for z in tweet["retweeted_status"]["extended_entities"]["media"]: for z in tweet["retweeted_status"]["extended_entities"]["media"]:
if "ext_alt_text" in z and z["ext_alt_text"] != None: if "ext_alt_text" in z and z["ext_alt_text"] != None:
image_description.append(z["ext_alt_text"]) image_description.append(z["ext_alt_text"])
self.message = message.viewTweet(text, rt_count, favs_count, source.decode("utf-8")) self.message = message.viewTweet(text, rt_count, favs_count, source)
self.message.set_title(len(text)) self.message.set_title(len(text))
[self.message.set_image_description(i) for i in image_description] [self.message.set_image_description(i) for i in image_description]
else: else:

View File

@ -29,7 +29,7 @@ def StripChars(s):
Else, a unicode string will be returned.""" Else, a unicode string will be returned."""
if match.group(1).startswith('#'): return chr(int(match.group(1)[1:])) if match.group(1).startswith('#'): return chr(int(match.group(1)[1:]))
replacement = html.entities.entitydefs.get(match.group(1), "&%s;" % match.group(1)) replacement = html.entities.entitydefs.get(match.group(1), "&%s;" % match.group(1))
return replacement.decode('iso-8859-1') return replacement
return str(entity_re.sub(matchFunc, s)) return str(entity_re.sub(matchFunc, s))
chars = "abcdefghijklmnopqrstuvwxyz" chars = "abcdefghijklmnopqrstuvwxyz"

View File

@ -13,7 +13,7 @@ class TinyArrowsShortener (URLShortener):
def _shorten (self, url): def _shorten (self, url):
answer = url answer = url
answer = urllib.request.urlopen("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.parse.quote(url)).read() answer = urllib.request.urlopen("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.parse.quote(url)).read()
return answer.decode('UTF-8') return answer
def created_url(self, url): def created_url(self, url):
return False return False