Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
0bcbe3c8
Commit
0bcbe3c8
authored
Aug 17, 2013
by
Aaron Hill
Browse files
Merge branch 'master' into pull_coverage
parents
6c650b32
577b0e5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
tests/test_api.py
View file @
0bcbe3c8
...
...
@@ -77,6 +77,12 @@ class TweepyAPITests(TweepyTestCase):
u
=
self
.
api
.
get_user
(
783214
)
self
.
assertEqual
(
u
.
screen_name
,
'twitter'
)
def
testlookupusers
(
self
):
def
check
(
users
):
self
.
assertEqual
(
len
(
users
),
2
)
check
(
self
.
api
.
lookup_users
(
user_ids
=
[
6844292
,
6253282
]))
check
(
self
.
api
.
lookup_users
(
screen_names
=
[
'twitterapi'
,
'twitter'
]))
def
testsearchusers
(
self
):
self
.
api
.
search_users
(
'twitter'
)
...
...
tests/test_utils.py
View file @
0bcbe3c8
...
...
@@ -8,3 +8,8 @@ class TweepyUtilsTests(TestCase):
result
=
parse_datetime
(
"Wed Aug 27 13:08:45 +0000 2008"
)
self
.
assertEqual
(
datetime
(
2008
,
8
,
27
,
13
,
8
,
45
),
result
)
def
testlist_to_csv
(
self
):
self
.
assertEqual
(
"1,2,3"
,
list_to_csv
([
1
,
2
,
3
]))
self
.
assertEqual
(
"bird,tweet,nest,egg"
,
list_to_csv
([
"bird"
,
"tweet"
,
"nest"
,
"egg"
]))
tweepy/models.py
View file @
0bcbe3c8
...
...
@@ -3,8 +3,7 @@
# See LICENSE for details.
from
tweepy.error
import
TweepError
from
tweepy.utils
import
parse_datetime
,
parse_html_value
,
parse_a_href
,
\
parse_search_datetime
,
unescape_html
from
tweepy.utils
import
parse_datetime
,
parse_html_value
,
parse_a_href
class
ResultSet
(
list
):
...
...
tweepy/utils.py
View file @
0bcbe3c8
...
...
@@ -14,6 +14,7 @@ from email.utils import parsedate
def
parse_datetime
(
string
):
return
datetime
(
*
(
parsedate
(
string
)[:
6
]))
def
parse_html_value
(
html
):
return
html
[
html
.
find
(
'>'
)
+
1
:
html
.
rfind
(
'<'
)]
...
...
@@ -26,41 +27,6 @@ def parse_a_href(atag):
return
atag
[
start
:
end
]
def
parse_search_datetime
(
string
):
# Set locale for date parsing
locale
.
setlocale
(
locale
.
LC_TIME
,
'C'
)
# We must parse datetime this way to work in python 2.4
date
=
datetime
(
*
(
time
.
strptime
(
string
,
'%a, %d %b %Y %H:%M:%S +0000'
)[
0
:
6
]))
# Reset locale back to the default setting
locale
.
setlocale
(
locale
.
LC_TIME
,
''
)
return
date
def
unescape_html
(
text
):
"""Created by Fredrik Lundh (http://effbot.org/zone/re-sub.htm#unescape-html)"""
def
fixup
(
m
):
text
=
m
.
group
(
0
)
if
text
[:
2
]
==
"&#"
:
# character reference
try
:
if
text
[:
3
]
==
"&#x"
:
return
unichr
(
int
(
text
[
3
:
-
1
],
16
))
else
:
return
unichr
(
int
(
text
[
2
:
-
1
]))
except
ValueError
:
pass
else
:
# named entity
try
:
text
=
unichr
(
htmlentitydefs
.
name2codepoint
[
text
[
1
:
-
1
]])
except
KeyError
:
pass
return
text
# leave as is
return
re
.
sub
(
"&#?\w+;"
,
fixup
,
text
)
def
convert_to_utf8_str
(
arg
):
# written by Michael Norton (http://docondev.blogspot.com/)
if
isinstance
(
arg
,
unicode
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment