projects
/
twitter-api-cdsw
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated packages and code to python3. Won't work with python 2
[twitter-api-cdsw]
/
tweepy
/
utils.py
diff --git
a/tweepy/utils.py
b/tweepy/utils.py
index e5d2a5ed917e41223881c24b69c330cd96f7a67a..36d340251986e029b11479140c4db6cfa40ea07f 100644
(file)
--- a/
tweepy/utils.py
+++ b/
tweepy/utils.py
@@
-2,11
+2,13
@@
# Copyright 2010 Joshua Roesslein
# See LICENSE for details.
# Copyright 2010 Joshua Roesslein
# See LICENSE for details.
+from __future__ import print_function
+
from datetime import datetime
from datetime import datetime
-import time
-import
re
-
import local
e
-from urllib import quote
+
+import
six
+
from six.moves.urllib.parse import quot
e
+
from email.utils import parsedate
from email.utils import parsedate
@@
-28,14
+30,13
@@
def parse_a_href(atag):
def convert_to_utf8_str(arg):
# written by Michael Norton (http://docondev.blogspot.com/)
def convert_to_utf8_str(arg):
# written by Michael Norton (http://docondev.blogspot.com/)
- if isinstance(arg,
unicod
e):
+ if isinstance(arg,
six.text_typ
e):
arg = arg.encode('utf-8')
arg = arg.encode('utf-8')
- elif not isinstance(arg,
str
):
- arg = s
tr(arg
)
+ elif not isinstance(arg,
bytes
):
+ arg = s
ix.text_type(arg).encode('utf-8'
)
return arg
return arg
-
def import_simplejson():
try:
import simplejson as json
def import_simplejson():
try:
import simplejson as json
@@
-44,16
+45,14
@@
def import_simplejson():
import json # Python 2.6+
except ImportError:
try:
import json # Python 2.6+
except ImportError:
try:
- from django.utils import simplejson as json # Google App Engine
+ # Google App Engine
+ from django.utils import simplejson as json
except ImportError:
raise ImportError("Can't load a json library")
return json
except ImportError:
raise ImportError("Can't load a json library")
return json
+
def list_to_csv(item_list):
if item_list:
return ','.join([str(i) for i in item_list])
def list_to_csv(item_list):
if item_list:
return ','.join([str(i) for i in item_list])
-
-def urlencode_noplus(query):
- return '&'.join(['%s=%s' % (quote(str(k), ''), quote(str(v), '')) \
- for k, v in query.iteritems()])
Benjamin Mako Hill
||
Want to submit a patch?