Fix handling of unicode in py2 - toot - Unnamed repository; edit this file 'description' to name the repository.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 64086cd0fe07cb037b20a681969dc302b113b8da
(DIR) parent a666689c8d7c53e15fdf2c639903ed0fd110e36c
(HTM) Author: Ivan Habunek <ivan@habunek.com>
Date: Mon, 17 Apr 2017 09:58:36 +0200
Fix handling of unicode in py2
Diffstat:
toot/api.py | 1 -
toot/console.py | 16 ++++++++--------
2 files changed, 8 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/toot/api.py b/toot/api.py
@@ -4,7 +4,6 @@ import logging
import requests
from requests import Request, Session
-from future.moves.urllib.parse import quote_plus
from toot import App, User, CLIENT_NAME, CLIENT_WEBSITE
(DIR) diff --git a/toot/console.py b/toot/console.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#
+from __future__ import unicode_literals
from __future__ import print_function
import os
@@ -25,19 +25,19 @@ class ConsoleError(Exception):
def red(text):
- return u"\033[31m{}\033[0m".format(text)
+ return "\033[31m{}\033[0m".format(text)
def green(text):
- return u"\033[32m{}\033[0m".format(text)
+ return "\033[32m{}\033[0m".format(text)
def yellow(text):
- return u"\033[33m{}\033[0m".format(text)
+ return "\033[33m{}\033[0m".format(text)
def blue(text):
- return u"\033[34m{}\033[0m".format(text)
+ return "\033[34m{}\033[0m".format(text)
def print_error(text):
@@ -287,7 +287,7 @@ def _find_account(app, user, account_name):
response = api.search(app, user, account_name, False)
for account in response['accounts']:
- if account['acct'] == account_name:
+ if account['acct'] == account_name or "@" + account['acct'] == account_name:
return account
@@ -306,7 +306,7 @@ def cmd_follow(app, user, args):
api.follow(app, user, account['id'])
- print(green(u"✓ You are now following %s" % args.account))
+ print(green("✓ You are now following %s" % args.account))
def cmd_unfollow(app, user, args):
@@ -324,7 +324,7 @@ def cmd_unfollow(app, user, args):
api.unfollow(app, user, account['id'])
- print(green(u"✓ You are no longer following %s" % args.account))
+ print(green("✓ You are no longer following %s" % args.account))
def cmd_whoami(app, user, args):