Skip to content

Commit

Permalink
OneDriveSDK#2: Fix how to concatenate strings to build a request
Browse files Browse the repository at this point in the history
Still needs some improvements, this is the initial commit only.
  • Loading branch information
derrix060 committed Nov 27, 2018
1 parent 848fc5b commit 2d0bf8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/onedrivesdk/extensions/drive_request_builder_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def item_by_path(self, path):
:class:`ItemRequestBuilder<onedrivesdk.requests.item_request_builder.ItemRequestBuilder>`:
A request builder for an item given a path
"""
#strip any leading '/'
path = str(path)[1:] if str(path)[0] == "/" else str(path)
return ItemRequestBuilder(self.append_to_request_url("root:/"+str(path)+":"), self._client)
path = str(path)[1:] if path.startswith(('/', ':')) else str(path)
return ItemRequestBuilder(self.append_to_request_url(
"root/" + path), self._client)

DriveRequestBuilder.item_by_path = item_by_path
7 changes: 6 additions & 1 deletion src/onedrivesdk/request_builder_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ def append_to_request_url(self, url_segment):
url_segment (str): The segment you would like to append
to the existing request URL.
"""
return self._request_url + "/" + url_segment
if url_segment.startswith(('/', ':')):
url_segment = url_segment[1:]
request_url = self._request_url
if self._request_url.endswith(('/', ':')):
request_url = request_url[:-1]
return request_url + "/" + url_segment
2 changes: 2 additions & 0 deletions src/python3/request/subscription_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def delete(self):
def delete_async(self):
"""Deletes the specified Subscription."""
yield from self.request().delete_async()

def get(self):
"""Gets the specified Subscription.
Expand All @@ -70,6 +71,7 @@ def get_async(self):
"""
entity = yield from self.request().get_async()
return entity

def update(self, subscription):
"""Updates the specified Subscription.
Expand Down

0 comments on commit 2d0bf8b

Please sign in to comment.