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
ab2be462
Commit
ab2be462
authored
Aug 19, 2012
by
Joshua Roesslein
Browse files
Merge pull request #156 from kodkultur/master
Implemented /friendships/lookup
parents
65a26c2b
aa055fe1
Changes
2
Hide whitespace changes
Inline
Side-by-side
tweepy/api.py
View file @
ab2be462
...
...
@@ -279,6 +279,19 @@ class API(object):
'target_id'
,
'target_screen_name'
]
)
""" Perform bulk look up of friendships from user ID or screenname """
def
lookup_friendships
(
self
,
user_ids
=
None
,
screen_names
=
None
):
return
self
.
_lookup_friendships
(
list_to_csv
(
user_ids
),
list_to_csv
(
screen_names
))
_lookup_friendships
=
bind_api
(
path
=
'/friendships/lookup.json'
,
payload_type
=
'relationship'
,
payload_list
=
True
,
allowed_param
=
[
'user_id'
,
'screen_name'
],
require_auth
=
True
)
""" friends/ids """
friends_ids
=
bind_api
(
path
=
'/friends/ids.json'
,
...
...
tweepy/models.py
View file @
ab2be462
...
...
@@ -292,6 +292,17 @@ class Relation(Model):
setattr
(
result
,
k
,
v
)
return
result
class
Relationship
(
Model
):
@
classmethod
def
parse
(
cls
,
api
,
json
):
result
=
cls
(
api
)
for
k
,
v
in
json
.
items
():
if
k
==
'connections'
:
setattr
(
result
,
'is_following'
,
'following'
in
v
)
setattr
(
result
,
'is_followed_by'
,
'followed_by'
in
v
)
else
:
setattr
(
result
,
k
,
v
)
return
result
class
JSONModel
(
Model
):
...
...
@@ -325,6 +336,7 @@ class ModelFactory(object):
search_result
=
SearchResult
list
=
List
relation
=
Relation
relationship
=
Relationship
json
=
JSONModel
ids
=
IDModel
...
...
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