Skip to content

Commit

Permalink
use consistent string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
msufa committed Nov 2, 2016
1 parent 1eb5f47 commit d342b57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions facebook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(self, access_token=None, timeout=None, version=None,

def get_object(self, id, **args):
"""Fetches the given object from the graph."""
return self.request(self.version + "/" + id, args)
return self.request("{0}/{1}".format(self.version, id), args)

def get_objects(self, ids, **args):
"""Fetches all of the given object from the graph.
Expand All @@ -117,7 +117,7 @@ def get_objects(self, ids, **args):
def get_connections(self, id, connection_name, **args):
"""Fetches the connections for given object."""
return self.request(
"%s/%s/%s" % (self.version, id, connection_name), args)
"{0}/{1}/{2}".format(self.version, id, connection_name), args)

def put_object(self, parent_object, connection_name, **data):
"""Writes the given object to the graph, connected to the given parent.
Expand All @@ -140,7 +140,7 @@ def put_object(self, parent_object, connection_name, **data):
"""
assert self.access_token, "Write operations require an access token"
return self.request(
self.version + "/" + parent_object + "/" + connection_name,
"{0}/{1}/{2}".format(self.version, parent_object, connection_name),
post_args=data,
method="POST")

Expand Down Expand Up @@ -173,11 +173,11 @@ def put_like(self, object_id):

def delete_object(self, id):
"""Deletes the object with the given ID from the graph."""
self.request(self.version + "/" + id, method="DELETE")
self.request("{0}/{1}".format(self.version, id), method="DELETE")

def delete_request(self, user_id, request_id):
"""Deletes the Request with the given ID for the given user."""
self.request("%s_%s" % (request_id, user_id), method="DELETE")
self.request("{0}_{1}".format(request_id, user_id), method="DELETE")

def put_photo(self, image, album_path="me/photos", **kwargs):
"""
Expand All @@ -188,7 +188,7 @@ def put_photo(self, image, album_path="me/photos", **kwargs):
"""
return self.request(
self.version + "/" + album_path,
"{0}/{1}".format(self.version, album_path),
post_args=kwargs,
files={"source": image},
method="POST")
Expand Down Expand Up @@ -282,7 +282,7 @@ def get_app_access_token(self, app_id, app_secret, offline=False):
access-tokens#apptokens>
"""
if offline:
return "%s|%s" % (app_id, app_secret)
return "{0}|{1}".format(app_id, app_secret)
else:
args = {'grant_type': 'client_credentials',
'client_id': app_id,
Expand Down Expand Up @@ -336,7 +336,7 @@ def debug_access_token(self, token, app_id, app_secret):
"""
args = {
"input_token": token,
"access_token": "%s|%s" % (app_id, app_secret)
"access_token": "{0}|{1}".format(app_id, app_secret)
}
return self.request("/debug_token", args=args)

Expand Down
2 changes: 1 addition & 1 deletion test/test_facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_get_offline_app_access_token(self):
"""Verify that offline generation of app access tokens works."""
token = facebook.GraphAPI().get_app_access_token(
self.app_id, self.secret, offline=True)
self.assertEqual(token, "%s|%s" % (self.app_id, self.secret))
self.assertEqual(token, "{0}|{1}".format(self.app_id, self.secret))

def test_get_deleted_app_access_token(self):
deleted_app_id = '174236045938435'
Expand Down

0 comments on commit d342b57

Please sign in to comment.